Skip to content

Instantly share code, notes, and snippets.

@FROGGS
Forked from gerdr/p003.pl
Last active December 12, 2015 01:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FROGGS/4691058 to your computer and use it in GitHub Desktop.
Save FROGGS/4691058 to your computer and use it in GitHub Desktop.
use v6;
sub largest-prime-factor($n is copy) {
for 2, 3, *+2 ... * {
while $n %% $_ {
$n div= $_;
return $_ if $_ > $n;
}
};
1
}
say largest-prime-factor(100);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment