Anti-primes: Difference between revisions

Initial FutureBasic task solution added
m (→‎{{header|Ruby}}: copy-paste error removed)
(Initial FutureBasic task solution added)
Line 2,143:
<pre>
1 2 4 6 12 24 36 48 60 120 180 240 360 720 840 1260 1680 2520 5040 7560
</pre>
 
=={{header|FutureBasic}}==
<syntaxhighlight lang="futurebasic">
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
</syntaxhighlight>
{{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>
 
715

edits