发布网友 发布时间:2024-10-23 22:45
共2个回答
热心网友 时间:2024-11-01 16:22
已试过,是对的,望采纳,谢谢
程序如下:
program fai0bonacai;
var t,n:longint;
p,l,f:real;
begin
read(n);
p:=0;l:=1;t:=2;
while t<>n do
begin
f:=p+l;
p:=l;
l:=f;
t:=t+1;
end;
write(f:0:0);
end.
附图:
热心网友 时间:2024-11-01 16:19
faibonacai(费波那契)数列
program minnum;
var
a:array[1..100] of longint;
n,i:integer;
begin
readln(n);
a[1]:=0;
a[2]:=1;
for i:=3 to n do
begin
a[i]:=a[i-1]+a[i-2];
end;
writeln(a[n]);
end.