Fibonacci series is special type of series which start's with 0 and 1 and in which every member in series is sum of it's previous two numbers.
Look here,
Explanation of Fibonacci Series...... |
#include<iostream>
using namespace std;
int main()
{
int f=0,s=1,A,i,n;
cout<<" Enter number of terms: ";
cin>>n;
cout<<" It is "<<n<<" terms Fibonacci series:"<<endl;
for(i=0; i<n; i++)
{
if(i<=1)
{
A=i;
}
else
{
A=f+s;
f=s;
s=A;
}
cout<<A<<",";
}
return 0;
}
INPUT && OUTPUT
0 Comments