Jump to content

Combinations with repetitions/Square digit chain: Difference between revisions

m
→‎{{header|Perl 6}}: minor update to working around warnings
mNo edit summary
m (→‎{{header|Perl 6}}: minor update to working around warnings)
Line 298:
}
}
 
quietly { # sweep warnings under the carpet
 
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>
}
 
} # to be continued</lang>
{{out}}
<pre>For k = 7 in the range 1 to 9999999
351

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.