9. fibonacci数列的前两项为0、1,以后的每一项都是其前两项之和。计算fibonacci数列前100项的值。
program exRecurrence9_1;
var
a1, a2, s : double;
i : integer;
begin
a1 := 0;
a2 := 1;
write(a1:0:0, ' ', a2:0:0, ' ');
for i := 3 to 100 do
begin
s := a1+a2;
a1 := a2;
a2 := s;
write(s:0:0, ' ');
if (i mod 10 = 0) then writeln;
end;
readln;
end.
var
a1, a2, s : double;
i : integer;
begin
a1 := 0;
a2 := 1;
write(a1:0:0, ' ', a2:0:0, ' ');
for i := 3 to 100 do
begin
s := a1+a2;
a1 := a2;
a2 := s;
write(s:0:0, ' ');
if (i mod 10 = 0) then writeln;
end;
readln;
end.