Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[Euler] Add solution for #168.
  • Loading branch information
shlomif committed Apr 18, 2014
1 parent ea0588e commit 4ac6dea
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions euler/prob168-shlomif.p6
@@ -0,0 +1,26 @@
use v6;

my $sum = 0;
# $multiplier is "d"
for 1 .. 9 -> $multiplier
{
for 1 .. 99 -> $L
{
# $digit is m.
for 1 .. 9 -> $digit
{
my $n = (((10 ** $L - $multiplier)*$digit)/(10*$multiplier - 1));

my $number_to_check = $n * 10 + $digit;
if ($n.chars() == $L and ($multiplier * $number_to_check
== $n + $digit * 10 ** $L))
{
print "Found $number_to_check\n";
$sum += $number_to_check;
print "Sum = $sum\n";
}
}
}
}

print "Last 5 digits of the final sum are: ", "$sum".substr(*-5), "\n";

0 comments on commit 4ac6dea

Please sign in to comment.