Last active
June 9, 2016 14:45
-
-
Save dogbert17/d7822b6db5daa88a372c835727bf0729 to your computer and use it in GitHub Desktop.
SEGV with HEAD or whatever camelia is running after 55 sec on my machine
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
# This is Rakudo version 2016.05-79-g2095ed6 built on MoarVM version 2016.05-17-g6075599 implementing Perl 6.c. | |
# What is the value of the first triangle number to have over five hundred divisors? | |
use v6; | |
my $numFactors = 500; | |
my $sum = 0; | |
for (1...*) -> $term { | |
$sum += $term; | |
my $factors = (1..floor(sqrt($sum))).grep(-> $x { $sum % $x == 0} ).elems * 2; | |
$factors-- if floor(sqrt($sum)) == sqrt($sum); | |
if $factors > $numFactors { | |
say "$sum"; | |
last; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment