23 lines
185 B
Plaintext
Raw Normal View History

import io
2024-07-31 00:03:16 +02:00
main() {
2024-08-02 15:06:32 +02:00
collatz(12)
}
2024-07-31 00:03:16 +02:00
2025-02-17 14:31:47 +01:00
collatz(x int) {
2024-07-31 00:03:16 +02:00
loop {
if x & 1 == 0 {
x /= 2
} else {
x = 3 * x + 1
}
2025-02-22 18:02:50 +01:00
io.number(x)
2024-07-31 00:03:16 +02:00
if x == 1 {
return
}
io.out(" ")
2024-07-31 00:03:16 +02:00
}
}