Permalink
Browse files

[Euler] Add solution for #168.

  • Loading branch information...
shlomif committed Apr 18, 2014
1 parent ea0588e commit 4ac6dea4720a8be7d474b709ee53f9a13f6abed7
Showing with 26 additions and 0 deletions.
  1. +26 −0 euler/prob168-shlomif.p6
View
@@ -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.