summaryrefslogtreecommitdiff
path: root/misc/pascal/tests/src/005-while.pas
blob: aceb5f4fa73a83781abaa00baa8f28cd0f148073 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
{ 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.