24 lines
207 B
Plaintext
Raw Normal View History

2024-07-30 22:03:16 +00:00
import log
import sys
main() {
2024-08-02 13:06:32 +00:00
collatz(12)
}
2024-07-30 22:03:16 +00:00
2024-08-05 16:47:24 +00:00
collatz(x Int) {
2024-07-30 22:03:16 +00:00
loop {
if x & 1 == 0 {
x /= 2
} else {
x = 3 * x + 1
}
log.number(x)
if x == 1 {
return
}
sys.write(1, " ", 1)
}
}