Skip to content

Instantly share code, notes, and snippets.

@dogbert17
Last active June 9, 2016 14:45
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 dogbert17/d7822b6db5daa88a372c835727bf0729 to your computer and use it in GitHub Desktop.
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 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