We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ea0588e commit 4ac6deaCopy full SHA for 4ac6dea
euler/prob168-shlomif.p6
@@ -0,0 +1,26 @@
1
+use v6;
2
+
3
+my $sum = 0;
4
+# $multiplier is "d"
5
+for 1 .. 9 -> $multiplier
6
+{
7
+ for 1 .. 99 -> $L
8
+ {
9
+ # $digit is m.
10
+ for 1 .. 9 -> $digit
11
12
+ my $n = (((10 ** $L - $multiplier)*$digit)/(10*$multiplier - 1));
13
14
+ my $number_to_check = $n * 10 + $digit;
15
+ if ($n.chars() == $L and ($multiplier * $number_to_check
16
+ == $n + $digit * 10 ** $L))
17
18
+ print "Found $number_to_check\n";
19
+ $sum += $number_to_check;
20
+ print "Sum = $sum\n";
21
+ }
22
23
24
+}
25
26
+print "Last 5 digits of the final sum are: ", "$sum".substr(*-5), "\n";
0 commit comments