Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add sigils so that example runs as perl
  • Loading branch information
Paul Cochrane committed Feb 23, 2015
1 parent 0acf1bd commit 6c028f8
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions euler/prob021-gerdr.pl
@@ -1,22 +1,22 @@
use v6;

sub d(Int \n) {
sub d(Int $n) {
my $sum = 1;
my \sqrt-n = sqrt n;
my $sqrt-n = sqrt $n;

for 2..Int(sqrt-n) -> \a {
my \b = n div a;
$sum += a + b if a * b == n;
for 2..Int($sqrt-n) -> $a {
my $b = $n div $a;
$sum += $a + $b if $a * $b == $n;
}

sqrt-n ~~ Int ?? $sum - sqrt-n !! $sum
$sqrt-n ~~ Int ?? $sum - $sqrt-n !! $sum;
}

my $sum = 0;

for 1..10_000 -> \a {
my \b = d(a);
$sum += a + b if a < b and d(b) == a;
for 1..10_000 -> $a {
my $b = d($a);
$sum += $a + $b if $a < $b and d($b) == $a;
}

say $sum;
Expand Down

0 comments on commit 6c028f8

Please sign in to comment.