fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int Fib(int n)
  5. {
  6. if (n==1) {return 1;}
  7. if (n==0) {return 0;}
  8. else {return Fib(n-1)+ Fib(n-2);}
  9. }
  10.  
  11. int x;
  12.  
  13. int main() {
  14. cin>>x;
  15. cout<<Fib(x);
  16. for (int i= 1; i<=x; i++)
  17. {
  18. cout<<Fib(i)<<endl;
  19. }
  20.  
  21. return 0;
  22. }
Success #stdin #stdout 0.01s 5316KB
stdin
5
stdout
51
1
2
3
5