Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use experimental :cached;
- sub collatz-len(Int $n) is cached
- {
- return $n == 1
- ?? 1
- !! 1 + collatz-len $n %% 2
- ?? $n div 2
- !! 3 * $n + 1;
- }
- say max (1..^1_000_000).race.map(&collatz-len);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement