Skip to content

Commit

Permalink
Fibonacci series without recursion
Browse files Browse the repository at this point in the history
  • Loading branch information
areenoverclouds committed May 25, 2021
1 parent 8a41ede commit 151738a
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions fibonacci.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <iostream>
using namespace std;

int main(){
int num1=0,num2=1,num3,i,n;
cout<<"\nEnter the number of elements of Fibonacci Series : ";
cin>>n;
cout<<num1<<' '<<num2<<' '; //First print 0 and 1

for(i=2;i<n;++i){
num3=num1+num2;
cout<<num3<<' ';
num1=num2;
num2=num3;
}
return 0;
}

0 comments on commit 151738a

Please sign in to comment.