Selasa, 30 Juni 2015

Pascal - Program Deret Fibonacci ( Iteratif )

Program Deret Fibonacci ( Iteratif ) menggunakan bahasa Pascal

program Fibonacci_Iteratif;
{Buatlah program deret fibonacci dengan batas sejumlah N.
 Contoh : N = 5, maka Output : 0, 1, 1, 2, 3. Program ini dibuat oleh
 SRI WAHYUNI-1400018214 pada tanggal 08 JUNI 2015 dengan SEJUJUR-JURURNYA.}

uses crt;

procedure fibonacci( N : integer);
var
   U1, U2, U3, i : integer;
begin
    U1 := 0;
    U2 := 1;
    for i := 1 to N do
    begin
        U3 := U1 + U2;
        if (i=1) then
        begin
           write(U1);
        end
        else
        begin
             if (i=2) then
             begin
                write(', ',U2);
             end
             else
             begin
                  write(', ',U3);
                  U1 := U2;
                  U2 := U3;
             end;
        end;
    end;
end;

var
   a : integer;
begin
writeln('=========================================');
writeln('|   PROGRAM DERET FIBONACCI(ITERATIF)   |');
writeln('|             SRI WAHYUNI               |');
writeln('|             1400018214                |');
writeln('|           <08 JUNI 2015>              |');
writeln('=========================================');
writeln(' ');

write('Masukkan batas : ');
readln(a);
write('Deret Fibonacci : ');
fibonacci(a);

end.


Hasil Compile :



Related Posts:

  • C++ PROGRAM MENCARI BILANGAN TERBESAR DAN TERKECIL ( CLASS ) C++ PROGRAM MENCARI BILANGAN TERBESAR DAN TERKECIL  ( CLASS ) #include <iostream> #include <cstdlib> using namespace std; /* run this program using the console pauser or add your own getch, system("pause") o… Read More
  • C++ Program Konversi Nilai UjianC++ Program Konversi Nilai Ujian #include <iostream> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ using namespace std; int main(int argc, char *argv[]) { … Read More
  • C++ PROGRAM PANGKAT (REKURSIF) C++  PROGRAM PANGKAT (REKURSIF) #include <iostream> #include <cstdlib> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ using namespace std; int pangkat(… Read More
  • C++ PROGRAM BILANGAN (terbesar, terkecil, rerata)C++ PROGRAM BILANGAN (terbesar, terkecil, rerata) #include <iostream> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ using namespace std; int main(int argc, char … Read More
  • C++ PROGRAM DERET FIBONACCI ITERATIF C++ PROGRAM DERET FIBONACCI ITERATIF #include <iostream> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ using namespace std; void fibonacci(int N){ int U1 = 0, U2 … Read More

0 komentar:

Posting Komentar