-
-
Save amankharwal/0337d23a278b5bf208a33c9687c6c601 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
using namespace std; | |
void fib(int n){ | |
int t1 = 0; | |
int t2 = 1; | |
int nextTerm; | |
for (int i = 1; i <= n; i++){ | |
cout<<t1<<endl; | |
nextTerm = t1 + t2; | |
t1 = t2; | |
t2 = nextTerm; | |
} | |
return; | |
} | |
int main(){ | |
int n; | |
cin>>n; | |
fib(n); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment