Combinations with repetitions/Square digit chain: Difference between revisions
Combinations with repetitions/Square digit chain (view source)
Revision as of 04:30, 23 December 2018
, 5 years ago→{{header|Perl 6}}: minor update to working around warnings
mNo edit summary |
m (→{{header|Perl 6}}: minor update to working around warnings) |
||
Line 298:
}
}
my @ks = (7, 8, 11, 14, 17);
for @ks -> $k {
my @sums = 1,0;
my $s;
Line 311 ⟶ 309:
$s = $j²;
if ($s > $i) { last };
@sums[$i-$s]:exists or @sums[$i-$s] = 0; # ugly work around
@sums[$i] += @sums[$i-$s];
}
Line 320 ⟶ 319:
say "For k = $k in the range 1 to $limit";
say "$count1 numbers produce 1 and ",$limit-$count1," numbers produce 89";
}</lang>
{{out}}
<pre>For k = 7 in the range 1 to 9999999
|