Skip to content

Commit 56e1476

Browse files
authored
Merge pull request #34 from MonalikaKapoor/Fibonacci-Series-Without-Recursion
Added code for Fibonacci_Series_Without_Recursion
2 parents 8a41ede + af2e4b7 commit 56e1476

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Fibonacci_Series_Without_Recursion

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include <iostream>
2+
using namespace std;
3+
int main() {
4+
int n1=0,n2=1,n3,i,number;
5+
cout<<"Enter the number of elements: ";
6+
cin>>number;
7+
cout<<n1<<" "<<n2<<" "; //printing 0 and 1
8+
for(i=2;i<number;++i) //loop starts from 2 because 0 and 1 are already printed
9+
{
10+
n3=n1+n2;
11+
cout<<n3<<" ";
12+
n1=n2;
13+
n2=n3;
14+
}
15+
return 0;
16+
}

0 commit comments

Comments
 (0)