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