Course of Raku / Addendum 🆕 / Working with data / Numbers and mathematics / Exercises
Collatz steps
Problem
Starting from a number, the Collatz process halves it when it is even
and replaces it with 3n + 1 when it is odd, repeating until
it reaches 1. Count how many steps it takes to bring
27 down to 1, and print that count.
Example
The program prints:
111