program Jumlah_deret_fibonacci;
uses crt;
Var
n,m,i,a,b,c,hasil : integer;
pilihan : char;
begin
repeat
clrscr;
writeln ('Program Hitung Jumlah Deret Fibonaccy');
writeln ('=====================================');
write ('Masukkan Banyaknya Deret : '); readln(n);
m := n ;
if (m >= 1000) and (m<1) then
begin
writeln (' Jumlah Deret Yang Anda Masukkan Salah ! ');
writeln (' 0 < Deret <= 1000 ');
write ('Masukkan Banyaknya Deret : '); readln(n);
end
else
hasil := 1;
a:= 0;
b:=1;
write ( a,' ', b,' ');
For i := 1 to n-1 do
begin
c:=a+b;
hasil := hasil + c;
write( c, ' ');
a:=b;
b:=c;
end;
writeln ('= ',hasil);
writeln (' ===================== ');
writeln (' INGIN MENGULANG ?(Y/T)');read(pilihan);
until pilihan = 't';
end.
tampilannya :
No comments:
Post a Comment