Created
June 23, 2019 12:48
-
-
Save dogbert17/02202b34d4c4cbcdff9632c1a2ac387c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# What is the largest prime factor of the number 600851475143 ? | |
use v6; | |
my $num = 600_851_475_143; | |
my $val = $num; | |
my @factors = (); | |
while ([*] @factors) != $num { | |
push @factors, (2...*).first(-> $x { $val %% $x && $x.is-prime }); | |
$val = $val div @factors[*-1]; | |
} | |
say @factors.max; # remove max to see all prime fact |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment