in reply to Learning math and efficient algorithms using perl

I try my best at Project Euler. Both fun and highly challenging.

Problem 12 reads Which is the first triangle number to have over five-hundred divisors?

I also play with PE and this is what I had used:

#!/usr/bin/perl -l use strict; use warnings; my $n; my @div=(0); while (++$n) { my ($m,$p)=($n,0); $m /= 2 and $p++ until $m & 1; $div[$n] = $p ? $div[$m]*$p : grep !($n%$_), 1..$n; print $n*($n-1)/2 and last if $div[$n]*$div[$n-1] > 500; } __END__