fork(1) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. void f(int last,int curr,int i, int n){
  4. if(i>n)
  5. return;
  6. int next = last+curr;
  7. last = curr;
  8. curr = next;
  9. cout<<next<<endl;
  10. f(last, curr, i+1,n);
  11. }
  12. int main() {
  13. // your code goes here
  14. int n=5;
  15. int last=0; int curr=1;
  16. int i=0;
  17. f(last,curr,i,n);
  18. }
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
1
2
3
5
8
13