Anti-primes: Difference between revisions
Content added Content deleted
m (→{{header|AWK}}: Added translated from, blank lines removed) |
|||
Line 1,044: | Line 1,044: | ||
5040 |
5040 |
||
7560</pre> |
7560</pre> |
||
=={{header|Objeck}}== |
|||
{{trans|Java}} |
|||
<lang objeck>class AntiPrimes { |
|||
function : Main(args : String[]) ~ Nil { |
|||
maxDiv := 0; count := 0; |
|||
"The first 20 anti-primes are:"->PrintLine(); |
|||
for(n := 1; count < 20; ++n;) { |
|||
d := CountDivisors(n); |
|||
if(d > maxDiv) { |
|||
"{$n} "->Print(); |
|||
maxDiv := d; |
|||
count++; |
|||
}; |
|||
}; |
|||
'\n'->Print(); |
|||
} |
|||
function : native : CountDivisors(n : Int) ~ Int { |
|||
if (n < 2) { return 1; }; |
|||
count := 2; |
|||
for(i := 2; i <= n/2; ++i;) { |
|||
if(n%i = 0) { ++count; }; |
|||
}; |
|||
return count; |
|||
} |
|||
}</lang> |
|||
{{output}} |
|||
<pre> |
|||
1 2 4 6 12 24 36 48 60 120 180 240 360 720 840 1260 1680 2520 5040 7560 |
|||
</pre> |
|||
=={{header|Pascal}}== |
=={{header|Pascal}}== |