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