Advertisement
Guest User

Untitled

a guest
Jan 19th, 2020
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main(){
  6.    
  7.     int n;
  8.     cin>>n;
  9.     int op_raod = 0;
  10.     while(n > 1){
  11.        
  12.        
  13.         # tu n luwia mashin gavyot orze
  14.         if(n % 2 == 0){
  15.             n /= 2;
  16.         }
  17.         # tu arada(n kentia) mashin gavamravlot 3ze da mivumatot 1
  18.         else{  
  19.             n = n * 3 + 1; 
  20.         }
  21.         # operaciebis raodenoba gavzardot ertit
  22.         op_raod ++;
  23.        
  24.         cout<<n<<" ";  
  25.     }  
  26.     cout<<endl;
  27.     cout<<op_raod;
  28.    
  29.        
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement