The Fibonacci Series is usually represented as follows-
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987,.......
C++ Program for Fibonacci Numbers
#include<iostream>
using namespace std;
int main()
{
int n;
cin>>n;
int a=0,b=1;
cout<<a<<", ";
cout<<b<<", ";
for (int i=1; i<=n; i++){
int fibnumber= a+b;
cout<<fibnumber<<", ";
a=b;
b=fibnumber;
}
}
0 Comments