Skip to content

Instantly share code, notes, and snippets.

@amankharwal
Created November 6, 2020 18:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amankharwal/0337d23a278b5bf208a33c9687c6c601 to your computer and use it in GitHub Desktop.
Save amankharwal/0337d23a278b5bf208a33c9687c6c601 to your computer and use it in GitHub Desktop.
#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