def collatz(n): while n != 1: print(n) if n % 2 == 0: n = n / 2 else: n = n * 3 + 1 collatz(127)
Standard input is empty
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