src2020/1661_jiaogu/jiaogu.cpp

19 lines
263 B
C++
Raw Permalink Normal View History

2020-04-24 14:28:43 +08:00
#include<iostream>
using namespace std; //<2F>ǹȲ<C7B9><C8B2><EFBFBD>
void dg(int n){
cout<<n<<endl;
if(n==1){
return;
}
if(n%2==0){
dg(n/2);
}else{
dg(n*3+1);
}
}
int main()
{
int n;
cin>>n;
dg(n);
}