Advertisement
Guest User

Untitled

a guest
Mar 27th, 2017
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.32 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int function(int i)
  5. {
  6.     if (i < 1) return 0;
  7.     if (i == 1) return 1;
  8.    
  9.     return function(i - 1) + function(i - 2);
  10. }
  11.  
  12. int main()
  13. {
  14.     int i = 0;
  15.     while (i < 10)
  16.     {
  17.         cout << function(i) << endl;
  18.         i++;
  19.     }
  20.    
  21.     return 0;    
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement