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