fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. int n, times = 0;
  5. scanf("%d", &n);
  6. while (n != 1) {
  7. if (n % 2 == 0)
  8. n /= 2;
  9. else if (n % 2 == 1)
  10. n = 3 * n + 1;
  11. times++;
  12. }
  13. printf("%d", times);
  14. return 0;
  15. }
  16.  
Success #stdin #stdout 0s 5320KB
stdin
5
stdout
5