#include<iostream>
#include<stdio.h>
#include<stdlib.h>
using namespace std;
int fibonacci(int x)
{
if(x==1)
return(0);
else if(x==2)
return(1);
else
return (fibonacci(x-1)+fibonacci(x-2));
}
int main()
{
int x;
cout<<"\nMasukan Jumlah Bilangan Fibonacci Yang Ingin Anda Tampilkan: ";cin>>x;
for(int y=1;y<=x;y++)
cout<<fibonacci(y)<<" ";
cout<<endl;
system("pause");
return(0);
}
0 komentar:
Posting Komentar