Home primes: Difference between revisions

m
→‎{{header|Raku}}: Add links, minor style twiddles
m (→‎{{header|Factor}}: tweak output)
m (→‎{{header|Raku}}: Add links, minor style twiddles)
Line 84:
 
=={{header|Raku}}==
 
Using [https://modules.raku.org/search/?q=Prime+Factor Prime::Factor] from the [https://modules.raku.org/ Raku ecosystem].
 
<lang perl6>use Prime::Factor;
 
for flat 2..20, 65 -> $m {
my ($n, $step, @steps, @factors) = $m, 0;
@steps.push: $n = @factors.join.Int while (@factors = prime-factors( $n)) > 1;
say "HP$m = ", (@steps[0..*-1]).map( { "{(++$sstep).fmt("HP$_\(%d)")}" } ).join(: ' = '),
my $s = 0;
say "HP$m = ", (@steps[0..*-1]).map( { "{(++$s).fmt("HP$_\(%d)")}" } ).join(' = '),
+@steps ?? " = {@steps.tail}" !! $m;
}</lang>
10,327

edits