RosettaCodeData/Task/Anti-primes/Run-BASIC/anti-primes.basic
2023-07-01 13:44:08 -04:00

36 lines
733 B
Text

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