Combinations with repetitions/Square digit chain: Difference between revisions
Combinations with repetitions/Square digit chain (view source)
Revision as of 04:13, 19 January 2021
, 3 years ago→{{header|Perl}}: speed up code with Math:AnyNum
(Added Wren) |
SqrtNegInf (talk | contribs) m (→{{header|Perl}}: speed up code with Math:AnyNum) |
||
Line 336:
{{trans|Raku}}
<lang perl>use strict;
use warnings;
use feature 'say';
use Math::AnyNum qw(:overload);
sub comma { reverse ((reverse shift) =~ s/(.{3})/$1,/gr) =~ s/^,//r }
Line 360:
}
my @ks = <7 8 11 14 17>;
for my $k (@ks) {
Line 368:
for my $i (reverse 1 .. $n*81) {
for my $j (1 .. 9) {
no warnings 'uninitialized';
last if ($s = $j**2) > $i;
$sums[$i] += $sums[$i-$s];
Line 390 ⟶ 391:
For k = 14 in the range 1 to 99,999,999,999,999
13,770,853,279,684 numbers produce 1 and 86,229,146,720,315 numbers produce 89
For k = 17 in the range 1 to 99,999,999,999,999,999
12,024,696,404,768,024 numbers produce 1 and 87,975,303,595,231,975 numbers produce 89</pre>
=={{header|Phix}}==
|