Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
12 lines (8 sloc) 220 Bytes
sub collatz-length(Int $start) {
+($start, { when * %% 2 { $_ div 2 }; when * !%% 2 { 3 * $_ + 1 }; } ... 1);
}
sub MAIN(*@numbers) {
for @numbers -> $n {
say "$n: " ~ collatz-length($n.Int);
}
}