It is a series starting from 0 or sometimes from 1 whose subsequent number is the sum of the previous two numbers. Example :-
0 | 1 | 1 | 2 | 3 | 5 | 8 | 13 | 21 | 34 | 55 | 89 | 144 | 233 | 377 | 610 | 987 | 1597 | 2584 | 4181 | 6765……… |
Source code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
| #include <iostream> #include<conio.h> #include<iomanip> using namespace std; int main() { long int i,f1=0,f2=1,f3,number; cout<<"Enter number :";cin>>number;cout<<endl; if(number>=1) cout<<"0"<<endl; if(number>=2) cout<<"1"<<endl; for(i=3;i<=number;i++) { f3=f1+f2; cout<<f3<<endl; f1=f2; f2=f3; } getch(); } |
No comments :
Post a Comment