|
|
|
|
|
by DanexCodr
170 days ago
|
|
// Other sample collatz := [1 to 1T]
for n in collatz {
steps := 0
current := n
while current != 1 {
current = if current % 2 == 0 { current/2 } else {3*current + 1}
steps += 1
}
collatz[n] = steps
} // On my phone, I can instantly check:
outln("27 takes " + collatz[27] + " steps") // 111 steps
outln("871 takes " + collatz[871] + " steps") // 178 steps |
|