fork download
  1. public class Main
  2. {
  3. public static void main(String[] args)
  4. {
  5. int i = 1;
  6. int x = 7;
  7.  
  8. while (x != 1)
  9. {
  10. System.out.println(i + " " + x);
  11.  
  12. if (x % 2 == 0)
  13. {
  14. x = x / 2;
  15. }
  16. else
  17. {
  18. x = x * 3 + 1;
  19. }
  20.  
  21. i++;
  22. }
  23.  
  24. System.out.println(i + " " + x);
  25. }
  26. }
Success #stdin #stdout 0.06s 380160KB
stdin
Standard input is empty
stdout
1 7
2 22
3 11
4 34
5 17
6 52
7 26
8 13
9 40
10 20
11 10
12 5
13 16
14 8
15 4
16 2
17 1