unit pr1 interface function extended integer extended function extende

 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
unit pr1;
interface
function g(x:extended;i:integer):extended;
function f(x:extended; i:integer):extended;
function step (x:integer; y:real):real;
procedure pogr (x:extended; p:extended; var res:integer);
implementation
function step(x:integer; y:real):real;
var
res:extended;
i:byte;
begin
res:=1;
for i:=1 to x do
res:=res*y;
step:=res;
end;
function g(x:extended;i:integer):extended;
var
res:extended;
begin
res:=1;
res:=-(step((i-1),x)*step((i-1),2))/step(i,5);
g:=res;
end;
function f(x:extended; i:integer):extended;
var
res:extended;
begin
res:=1;
for i:=1 to i do
res:=res+g(x,i);
f:=res;
end;
procedure pogr (x:extended; p:extended; var res:integer);
var
n,m:integer;
begin
n:=0;
for m:=1 to 100 do
begin
n:=n+1;
if (g(x,n)-g(x,n+1))<p then break;
end;
res:=n+1;
f(x,res);
end;
end.