Home > Ren's Free Time > Deret Fibonacci dengan Rekursif

Deret Fibonacci dengan Rekursif

Berikut ini merupakan algoritma untuk menampilkan deret fibonaci dengan rekursif.

rumus fibonacci yaitu

fibonacci(n)

  • n=1 || n = 0  ->1
  • n>1  -> fibonacci (n-1) + fibonacci (n-2)

C/C++ dengan borland turbo C++

#include<iostream.h>
#include <conio.h>
void fibonaci(int n);

int main()
{
clrscr ( );
int jumlah;
cout<<"jumlah bilangan Fibonaci yang ingin ditampilkan";
cin >> jumlah;
for(int i=0; i<jumlah; i++)
{
fibonaci( jumlah);
}
return 0;

}
int fibonaci(int n)
{
if( n<=2)
{
return 1;
}
else
{
return (fibonaci(n-1) + fibonaci (n-2));
}
cout <<"\n";
getch();
}

Fibonacci dengan Rekursif

About these ads
  1. andre
    October 17, 2012 at 14:11

    ga bisa woi

  2. Ren
    October 26, 2012 at 19:46

    So?

  3. tito
    January 7, 2013 at 01:30

    thkzz… gan

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: