src2020/1807_CollatzConjecture/1807_CollatzConjecture.cpp

16 lines
248 B
C++

#include<iostream>
using namespace std; //½Ç¹È²ÂÏë
int main()
{
int n;
cin>>n;
while(n!=1){
cout<<n<<endl;
if(n%2!=0){
n=n*3+1;
}else{
n/=2;
}
}
cout<<"1";
}