Amicable pairs: Difference between revisions
m
Zig now before zkl
m (→{{header|ALGOL 60}}: corrected minor typo) |
Recombinant (talk | contribs) m (Zig now before zkl) |
||
Line 6,708:
print : print peek("millisrunning"), " ms"</syntaxhighlight>
=={{header|zkl}}==▼
Slooooow▼
<syntaxhighlight lang="zkl">fcn properDivs(n){ [1.. (n + 1)/2 + 1].filter('wrap(x){ n%x==0 and n!=x }) }▼
const N=20000;▼
sums:=[1..N].pump(T(-1),fcn(n){ properDivs(n).sum(0) });▼
[0..].zip(sums).filter('wrap([(n,s)]){ (n<s<=N) and sums[s]==n }).println();</syntaxhighlight>▼
{{out}}▼
<pre>▼
L(L(220,284),L(1184,1210),L(2620,2924),L(5020,5564),L(6232,6368),L(10744,10856),L(12285,14595),L(17296,18416))▼
</pre>▼
=={{header|Zig}}==
Line 6,763 ⟶ 6,752:
12285, 14595
17296, 18416</pre>
▲=={{header|zkl}}==
▲Slooooow
▲<syntaxhighlight lang="zkl">fcn properDivs(n){ [1.. (n + 1)/2 + 1].filter('wrap(x){ n%x==0 and n!=x }) }
▲const N=20000;
▲sums:=[1..N].pump(T(-1),fcn(n){ properDivs(n).sum(0) });
▲[0..].zip(sums).filter('wrap([(n,s)]){ (n<s<=N) and sums[s]==n }).println();</syntaxhighlight>
▲{{out}}
▲<pre>
▲L(L(220,284),L(1184,1210),L(2620,2924),L(5020,5564),L(6232,6368),L(10744,10856),L(12285,14595),L(17296,18416))
▲</pre>
=={{header|ZX Spectrum Basic}}==
|