Tuesday, 9 April 2013

Fibonacci series in c++ smart code

fibonacci series c++






#include<iostream>
using namespace std;
int fibonacci_series(int i)
{
if(i==1)
{
return 0;
}
else if(i<3)
{

return 1;
}
else
{
return (fibonacci_series(i-1)+fibonacci_series(i-2));//call recursive function
}
}

void main()
{

int limit;
cout<<" Insert the limit of fibonacci series:";
cin>>limit;

for(int a=1;a<=limit;a++)
{
cout<<fibonacci_series(a)<<",";
}

}


c++ games


c++ recursive functions

0 comments:

Post a Comment