FIBONANCI
//Program menetapkan bilangan Fibonanci
#include <iostream.h>
#include <conio.h>
main()
{
const int MAX = 100;
int bilangan, i, k, fibo[100];
bilangan=0;
while ((bilangan<1) || (bilangan>100))
{
cout << "Inputkan bilangan bulat ! ";
cin >> bilangan;
}
for(i=1;i<=bilangan;i++)
{
if(i==1 || i==2) fibo[i]=1;
else
fibo[i]=fibo[i-1]+fibo[i-2];
}
cout << "Bilangan Fibonanci : ";
for (i=1;i<=bilangan;i++) cout << fibo[i] << " ";
cout << endl;
getch();
}
Comments
Post a Comment