Anti-primes: Difference between revisions

m (→‎{{header|REXX}}: elided REXX version 2.)
Line 186:
1 2 4 6 12 24 36 48 60 120 180 240 360 720 840 1260 1680 2520 5040 7560
</pre>
 
=={{header|Julia}}==
<lang julia>using Primes, Combinatorics
 
function antiprimes(N, max = 1000000)
antip = [1] # special case: 1 is antiprime
count = 1
maxfactors = 1
for i in 2:2:max # antiprimes > 2 should be even
lenfac = length(unique(sort(collect(combinations(factor(Vector, i)))))) + 1
if lenfac > maxfactors
push!(antip, i)
if length(antip) >= N
return antip
end
maxfactors = lenfac
end
end
antip
end
 
println("The first 20 anti-primes are:\n", antiprimes(20))
</lang>{{output}}<pre>
The first 20 anti-primes are:
[1, 2, 4, 6, 12, 24, 36, 48, 60, 120, 180, 240, 360, 720, 840, 1260, 1680, 2520, 5040, 7560]
</pre>
 
 
=={{header|Kotlin}}==
4,111

edits