Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main(){
- int n;
- cin>>n;
- int op_raod = 0;
- while(n > 1){
- # tu n luwia mashin gavyot orze
- if(n % 2 == 0){
- n /= 2;
- }
- # tu arada(n kentia) mashin gavamravlot 3ze da mivumatot 1
- else{
- n = n * 3 + 1;
- }
- # operaciebis raodenoba gavzardot ertit
- op_raod ++;
- cout<<n<<" ";
- }
- cout<<endl;
- cout<<op_raod;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement