fork(1) download
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. void fibonacci(int m){
  6. int t1=0;
  7. int t2=1;
  8. int next_term;
  9. for(int i=1;i<=m;i++){
  10. cout << t1;
  11. next_term = t1+t2;
  12. t2 = next_term;
  13. t1 = t2;
  14. }
  15. return;
  16. }
  17.  
  18.  
  19. int main()
  20. {
  21. int n;
  22. cin >> n;
  23. fibonacci(n);
  24.  
  25. return 0;
  26. }
  27.  
  28.  
  29.  
Success #stdin #stdout 0.01s 5444KB
stdin
5
stdout
01248