40 lines
745 B
Plaintext
40 lines
745 B
Plaintext
local fn DivisorCount( v as long ) as long
|
|
long total = 1, n = v, p, count
|
|
|
|
while ( n mod 2 ) == 0
|
|
total++
|
|
n = int( n / 2 )
|
|
wend
|
|
p = 3
|
|
while ( p * p ) <= n
|
|
count = 1
|
|
while ( n mod p ) == 0
|
|
count++
|
|
n = int( n / p )
|
|
wend
|
|
p = p + 2
|
|
total = total * count
|
|
wend
|
|
if n > 1 then total = total * 2
|
|
end fn = total
|
|
|
|
void local fn AntiPrimes( howMany as long )
|
|
long n = 0, count = 0, divisors, max_divisors = 0
|
|
|
|
printf @"The first %ld anti-primes are:", howMany
|
|
|
|
while ( count < howMany )
|
|
n++
|
|
divisors = fn DivisorCount( n )
|
|
if ( divisors > max_divisors )
|
|
printf @"%ld \b", n
|
|
max_divisors = divisors
|
|
count++
|
|
end if
|
|
wend
|
|
end fn
|
|
|
|
fn AntiPrimes( 20 )
|
|
|
|
HandleEvents
|