24 lines
207 B
Plaintext
24 lines
207 B
Plaintext
import log
|
|
import sys
|
|
|
|
main() {
|
|
collatz(12)
|
|
}
|
|
|
|
collatz(x Int) {
|
|
loop {
|
|
if x & 1 == 0 {
|
|
x /= 2
|
|
} else {
|
|
x = 3 * x + 1
|
|
}
|
|
|
|
log.number(x)
|
|
|
|
if x == 1 {
|
|
return
|
|
}
|
|
|
|
sys.write(1, " ", 1)
|
|
}
|
|
} |