• Source
    1. #include <iostream>
    2. using namespace std;
    3.  
    4. int main ()
    5. {
    6. int N;
    7. while (1)
    8. {
    9. cin>>N;
    10. if (N==0) break;
    11. int count=1;
    12. while (N!=1)
    13. {
    14. if (N%2==0) N=N/2;
    15. else N=(N*3)+1;
    16. count++;
    17. }
    18. cout<<count<<endl;
    19. }
    20. return 0;
    21. }