Anti-primes: Difference between revisions

Content added Content deleted
m (→‎even and odd numbers: simplified the code.)
Line 1,786: Line 1,786:
return count
return count
end sub</lang>
end sub</lang>

{{trans|Lua}}
<lang Yabasic>// First 20 antiprimes.
sub count_factors(number)
local count, attempt
for attempt = 1 to number
if not mod(number, attempt) count = count + 1
next
return count
end sub
sub antiprimes$(goal)
local factors, list$, number, mostFactors, nitems
number = 1
while nitems < goal
factors = count_factors(number)
if factors > mostFactors then
list$ = list$ + ", " + str$(number)
nitems = nitems + 1
mostFactors = factors
endif
number = number + 1
wend
return list$
end sub

print "The first 20 antiprimes:"
print mid$(antiprimes$(20), 3)
print "Done."</lang>


=={{header|zkl}}==
=={{header|zkl}}==