pascal斐波那契数列 要用repeat语句做求数列:1,1,2,3,5,8,13,21,34,55,……的第n项的值.

来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/27 12:01:50
pascal斐波那契数列要用repeat语句做求数列:1,1,2,3,5,8,13,21,34,55,……的第n项的值.pascal斐波那契数列要用repeat语句做求数列:1,1,2,3,5,8,1

pascal斐波那契数列 要用repeat语句做求数列:1,1,2,3,5,8,13,21,34,55,……的第n项的值.
pascal斐波那契数列 要用repeat语句做
求数列:1,1,2,3,5,8,13,21,34,55,……的第n项的值.

pascal斐波那契数列 要用repeat语句做求数列:1,1,2,3,5,8,13,21,34,55,……的第n项的值.
var
n,x,y,z,s:integer;
begin
readln(n);
x:=1;
y:=1;
s:=2;
repeat
z:=x+y;
x:=y;
y:=z;
inc(s);
until s=n;
write(z);
end.