Friday, July 5, 2013

Program Pascal Barisan Fibonacci (Souce Code)

program Barisan_Fibbonancy;
var
  N : integer;

Procedure Isi_N(var N : integer);
begin
  writeln('Membuat Barisan Fibbonancy');
  writeln('--------------------------');
  write('Masukan Harga N : ');readln(N);
end;
Function Fibbonancy(N : integer) : integer;
begin
  if(N = 1) or (N = 2)
    then
      Fibbonancy := 1
    else
      Fibbonancy := Fibbonancy(N-2) + Fibbonancy(N-1);
end;
Procedure Tampil_Fibbonancy(N : integer);
var
  i : integer;
begin
  write('Barisan Fibbonancy sebanyak ',N,' suku adalah ');
  for i := 1 to N do
  begin
    write(Fibbonancy(i));
    if(i <> N)
     then
       write(', ');
  end;
end;
begin
  Isi_N(N);
  Tampil_Fibbonancy(N);
  readln;
end.

0 comments: