fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. // your code goes here
  5. int n,count;
  6. n=30;
  7. count=0;
  8. while(n!=1){
  9. if(n%2==0)n=n/2;
  10. else n=3*n+1;
  11. count++;
  12. printf("%d ",n);
  13. }
  14. printf("\n%d回",count);
  15. return 0;
  16. }
  17.  
Success #stdin #stdout 0.01s 5292KB
stdin
Standard input is empty
stdout
15 46 23 70 35 106 53 160 80 40 20 10 5 16 8 4 2 1 
18回