fork(3) download
  1. def collatz(n):
  2. while n != 1:
  3. print(n)
  4. if n % 2 == 0:
  5. n = n / 2
  6. else:
  7. n = n * 3 + 1
  8.  
  9. collatz(127)
Success #stdin #stdout 0.02s 28384KB
stdin
Standard input is empty
stdout
127
382
191.0
574.0
287.0
862.0
431.0
1294.0
647.0
1942.0
971.0
2914.0
1457.0
4372.0
2186.0
1093.0
3280.0
1640.0
820.0
410.0
205.0
616.0
308.0
154.0
77.0
232.0
116.0
58.0
29.0
88.0
44.0
22.0
11.0
34.0
17.0
52.0
26.0
13.0
40.0
20.0
10.0
5.0
16.0
8.0
4.0
2.0