Combinations with repetitions/Square digit chain: Difference between revisions
Content added Content deleted
mNo edit summary |
m (→{{header|Perl 6}}: minor update to working around warnings) |
||
Line 298: | Line 298: | ||
} |
} |
||
} |
} |
||
quietly { # sweep warnings under the carpet |
|||
my @ks = (7, 8, 11, 14, 17); |
my @ks = (7, 8, 11, 14, 17); |
||
for @ks -> $k { |
for @ks -> $k { |
||
my @sums = 1,0; |
my @sums = 1,0; |
||
my $s; |
my $s; |
||
Line 311: | Line 309: | ||
$s = $j²; |
$s = $j²; |
||
if ($s > $i) { last }; |
if ($s > $i) { last }; |
||
@sums[$i-$s]:exists or @sums[$i-$s] = 0; # ugly work around |
|||
@sums[$i] += @sums[$i-$s]; |
@sums[$i] += @sums[$i-$s]; |
||
} |
} |
||
Line 320: | Line 319: | ||
say "For k = $k in the range 1 to $limit"; |
say "For k = $k in the range 1 to $limit"; |
||
say "$count1 numbers produce 1 and ",$limit-$count1," numbers produce 89"; |
say "$count1 numbers produce 1 and ",$limit-$count1," numbers produce 89"; |
||
}</lang> |
|||
} |
|||
} # to be continued</lang> |
|||
{{out}} |
{{out}} |
||
<pre>For k = 7 in the range 1 to 9999999 |
<pre>For k = 7 in the range 1 to 9999999 |