25.07.2021, 03:28
общий
это ответ
Можно так.
[code lang=pascal]uses crt;
var n,i:integer;
s,s1,f,p:real; {при больших n может быть выход за пределы целых типов}
begin
clrscr;
repeat
write('Enter the natural n>2 n=');
readln(n);
until n>2;
{цикл for}
s:=0;
s1:=0;
f:=1;
for i:=0 to n+1 do
begin
if i>=3 then s:=s+(i-2);
if i<=n then s1:=s1+i;
if i>1 then f:=f*i;
end;
p:=s/f/n-s1;
writeln('Pfor=',p:0:5);
{цикл while}
s:=0;
s1:=0;
f:=1;
i:=0;
while i<=n+1 do
begin
if i>=3 then s:=s+(i-2);
if i<=n then s1:=s1+i;
if i>1 then f:=f*i;
i:=i+1;
end;
p:=s/f/n-s1;
writeln('Pwhile=',p:0:5);
{цикл repeat until}
s:=0;
s1:=0;
f:=1;
i:=0;
repeat
if i>=3 then s:=s+(i-2);
if i<=n then s1:=s1+i;
if i>1 then f:=f*i;
i:=i+1;
until i>n+1;
p:=s/f/n-s1;
writeln('Prepeat=',p:0:5);
readln
end.[/code]