Code C++
#include <iostream>
using namespace std;
int f(unsigned int x)
{
if(x <= 1) return 1;
else return f(x-1)+f(x-2);
}
int main()
{
int total=0;
int input;
cout << "Masukan batas akhir fibonanci : ";
cin >> input;
for(int i = 0; i <= input - 1 ; i++)
{
cout << f(i) << " ";
total = total+f(i);
}
cout << "\nJumlah Semuanya : " << total << endl;
return 0;
}
Subscribe to:
Post Comments (Atom)

0 Response to "Membuat Deret Fibonanci dengan Recursive C++"
Post a Comment