daily pastebin goal
70%
SHARE
TWEET

Untitled

a guest Nov 21st, 2017 45 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<iostream>  
  2. #include<cmath>  
  3. using namespace std;  
  4. int power(int a);  
  5. int main()  
  6. {  
  7.     int a;  
  8.     cin >> a;  
  9.     cout << power(a) << endl;  
  10. }  
  11.  
  12. int power(int a)  
  13. {  
  14.     if (a==1)  
  15.     {  
  16.         return 1;  
  17.     }  
  18.     else if (a==2)  
  19.     {  
  20.         return 2;  
  21.     }  
  22.     else  
  23.     {  
  24.         return power(a - 1) + power(a - 2);  
  25.     }  
  26. }
RAW Paste Data
Top