Anti-primes: Difference between revisions

Anti-primes in Run BASIC
(Anti-primes in Run BASIC)
Line 834:
1 2 4 6 12 24 36 48 60 120 180 240 360 720 840 1260 1680 2520 5040 7560
</pre>
 
==={{header|Run BASIC}}===
{{works with|Just BASIC}}
{{works with|Liberty BASIC}}
<syntaxhighlight lang="lb">MaxAntiPrime = 20
n = 0
MaxDivisors = 0
AntiPrimeCount = 0
print "The first 20 anti-primes are: "
while AntiPrimeCount < MaxAntiPrime
n = n +1
Divisors = DivisorCount(n)
if Divisors > MaxDivisors then
print n; " ";
MaxDivisors = Divisors
AntiPrimeCount = AntiPrimeCount +1
end if
wend
end
 
function DivisorCount(v)
total = 1
n = v
while n mod 2 = 0
total = total +1
n = int(n / 2)
wend
p = 3
while (p * p) <= n
count = 1
while n mod p = 0
count = count +1
n = int(n / p)
wend
p = p +2
total = total * count
wend
if n > 1 then total = total *2
DivisorCount = total
end function</syntaxhighlight>
{{out}}
<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|Tiny BASIC}}===
2,130

edits