Uses wincrt;
Var i,n,f,f1,f2 : integer;
begin
clrscr;
writeln('Ingin mencetak bilangan Fibonacci');
write('sampai suku ke-');
readln(n);
writeln;
writeln('Suku ke- 1 = ',1);
writeln('Suku ke- 2 = ',1);
f1 :=1; f2:=1;
for i:=3 to n do
begin
f:=f1+f2;
writeln('Suku ke- ',i:2,' = ',F:3);
f2:=f1; f1:=f;
end;
readln;
end.
0 comments:
Post a Comment