Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
17 lines (13 sloc) 268 Bytes
sub collatz-length(Int $n is copy) {
my $length = 1;
while $n != 1 {
$n = $n %% 2 ?? $n div 2 !! 3 * $n + 1;
$length++;
}
$length;
}
sub MAIN(*@numbers) {
for @numbers -> $n {
say "$n: " ~ collatz-length($n.Int);
}
}
Something went wrong with that request. Please try again.