Program deret Fibonacci Sederhana Bahasa Pemograman Pascal
Berikut Source Code Fibonacci dengan bahasa Pascal :
Program UTS_algo ;
Uses Wincrt ;
Const
n = 20 ;
Deret : array[1..n] of integer = (1,2,3,4,5,6,7,8,9,10,11,12,13,14,
15,16,17,18,19,20) ;
Var
i, x : integer ;
Begin Clrscr ;
Write('Deret fibonaci dengan n= : ');
Readln(x) ;
Writeln;
Deret[1]:= 1 ;
Deret[2]:= 1 ;
For i:=3 to x do
Begin
Deret[i]:= deret[i-1]+deret[i-2] ;
end ;
Writeln('Maka deret fibonaci anda: ') ;
For i:=1 to (x-1) Do
Begin
Write(Deret[i],', ') ;
End ;
Write(Deret[x]) ;
End.
Thursday, June 10, 2010
12:29 PM
ethnies
No comments
0 comments:
Post a Comment