PX4-Autopilot/misc/pascal/tests/src/004-repeat.pas
2011-12-19 19:24:09 +00:00

19 lines
244 B
ObjectPascal

{ compute h(n) = 1 + 1/2 + 1/3 +...+ 1/n }
program egrepeat(input, output);
var
n : integer;
h : real;
begin
read(n);
writeln(n);
h := 0;
repeat
h := h + 1/n;
n := n - 1;
until n=0;
writeln(h);
end.