Advertisement
ivangarvanliev

Untitled

Jun 3rd, 2024
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.31 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5.     long long n;
  6.     cin>>n;
  7.    
  8.     while(n!=1){
  9.         cout<<n<<" ";
  10.         if(n%2==0){
  11.              n=n/2;
  12.            
  13.         }
  14.         else{
  15.             n=n*3 + 1;
  16.            
  17.         }
  18.     }
  19.     cout<<"1";
  20.     return 0;
  21. }
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement