program p8_2_a uses crt function fs integer real var integer real begi

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
program p8_2_a;
uses crt;
function fs(n : integer) : real;
var k : integer; s: real;
begin
k := 2; s := 1;
repeat
s := s + 1/sqrt(k);
k := k + 1;
until k > n;
fs := s;
end;
var n : integer; s : real;
begin
clrscr;
writeln('pi*pi/6 = ', pi * pi / 6:2:20);
s := fs(10);
writeln('n = 10, s = ', s:2:20);
s := fs(20);
writeln('n = 20, s = ', s:2:20);
s := fs(30);
writeln('n = 30, s = ', s:2:20);
readln;
end.