Anonymous user
Anti-primes: Difference between revisions
no edit summary
(Added Ada) |
No edit summary |
||
Line 684:
7560
Done.</pre>
=={{header|Nim}}==
<lang nim># First 20 antiprimes
proc countDivisors(n: int): int =
if (n < 2):
return 1
var count = 2
for i in countup(2, (n / 2).toInt()):
if (n %% i == 0):
count += 1
return count
proc antiPrimes(n: int) =
echo("The first ", n, " anti-primes:")
var maxDiv = 0
var count = 0
var i = 1
while(count < n):
let d = countDivisors(i)
if (d > maxDiv):
echo(i)
maxDiv = d
count+=1
i += 1
antiPrimes(20)
</lang>
{{output}}
<pre>The first 20 antiprimes:
1
2
4
6
12
24
36
48
60
120
180
240
360
720
840
1260
1680
2520
5040
7560</pre>
=={{header|Pascal}}==
|