Skip to content

Commit 8c1c641

Browse files
committed
[euler/prob003] add more 6ish version that works with current Rakudo
1 parent 7d9c163 commit 8c1c641

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

euler/prob003-gerdr.pl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
use v6;
2+
3+
sub largest-prime-factor($n is copy) {
4+
my @primes;
5+
for 2, 3, *+2 ... * -> $p {
6+
next if $p %% any @primes.grep({ $_ * $_ <= $p or last});
7+
@primes.push($p);
8+
while $n %% $p {
9+
$n div= $p;
10+
return $p if $p >= $n;
11+
}
12+
}
13+
}
14+
15+
say largest-prime-factor(600851475143);

0 commit comments

Comments
 (0)