Coding menampilkan Bilangan Fibonacci yang kurang dari sama dengan N dengan menggunakan program Delphi.
procedure TForm7.Button1Click(Sender: TObject);
var n,a,b,c :integer;
begin
n := strtoint (edit1.Text);
a := 1;
b := 1 ;
c := a + b;
if n >= 1 then listbox1.items.add (inttostr(b));
listbox1.items.add (inttostr(a));
if n >= 2 then listbox1.items.add (inttostr(c));
while c <= n -b do
begin
a:= b ;
b:= c ;
c:= a+b;
listbox1.items.add (inttostr(c));
end;
end;
0 komentar:
Post a Comment