Files
PX4-Autopilot/misc/pascal/tests/src/005-while.pas
T
patacongo 57623d42eb Resync new repository with old repo r5166
git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5153 42af7a65-404d-4744-a932-0658087f49c3
2012-09-17 18:18:44 +00:00

20 lines
233 B
ObjectPascal

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