Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<cmath>
- using namespace std;
- int power(int a);
- int main()
- {
- int a;
- cin >> a;
- cout << power(a) << endl;
- }
- int power(int a)
- {
- if (a==1)
- {
- return 1;
- }
- else if (a==2)
- {
- return 2;
- }
- else
- {
- return power(a - 1) + power(a - 2);
- }
- }
Add Comment
Please, Sign In to add comment