Created
September 23, 2021 18:04
-
-
Save dogbert17/162bcbb76f61a406ee1a245d36fca18f to your computer and use it in GitHub Desktop.
JIT error
This file contains hidden or 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 factors |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment