Anti-primes: Difference between revisions

Content added Content deleted
m (→‎{{header|Sidef}}: added zkl header)
(→‎{{header|zkl}}: added code)
Line 322: Line 322:


=={{header|zkl}}==
=={{header|zkl}}==
{{trans|Perl6}}
<lang zkl></lang>
<lang zkl>fcn properDivsN(n) //--> count of proper divisors. 1-->1, wrong but OK here
<lang zkl></lang>
{ [1.. (n + 1)/2 + 1].reduce('wrap(p,i){ p + (n%i==0 and n!=i) }) }
fcn antiPrimes{ // -->iterator
Walker.chain([2..59],[60..*,30]).tweak(fcn(c,rlast){
last,mx := rlast.value, properDivsN(c);
if(mx<=last) return(Void.Skip);
rlast.set(mx);
c
}.fp1(Ref(0))).push(1); // 1 has no proper divisors
}</lang>
<lang zkl>println("First 20 anti-primes:\n ",antiPrimes().walk(20).concat(" "));</lang>
{{out}}
{{out}}
<pre>
<pre>
First 20 anti-primes:
1 2 4 6 12 24 36 48 60 120 180 240 360 720 840 1260 1680 2520 5040 7560
</pre>
</pre>