Advertisement
Guest User

Fibonaccy

a guest
Jun 20th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.36 KB | None | 0 0
  1. #include<iostream>
  2.  
  3. using namespace std;
  4. #ifdef BYREF
  5. int fibonacci(const int& n)
  6. #else
  7. int fibonacci(int n)
  8. #endif
  9. {
  10.     if ((n == 1) || (n == 0))
  11.         return n;
  12.     else
  13.         return fibonacci(n - 1) + fibonacci(n - 2);
  14. }
  15.  
  16. int main()
  17. {
  18.     for (int i = 0; i < 1000; ++i)
  19.     {
  20.         std::cout << " " << fibonacci(i);
  21.     }
  22.     return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement