mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 03:51:18 +00:00
36 lines
610 B
Plaintext
36 lines
610 B
Plaintext
module antiprime;
|
|
import std::io;
|
|
|
|
extern func int printf(char* message, ...);
|
|
|
|
func int countDivisors(int n)
|
|
{
|
|
if (n < 2) return 1;
|
|
int count = 2;
|
|
for (int i = 2; i <= n / 2; i++)
|
|
{
|
|
if (n % i == 0) count++;
|
|
}
|
|
return count;
|
|
}
|
|
|
|
func int main()
|
|
{
|
|
int maxDiv;
|
|
int count;
|
|
io::println("The first 20 anti-primes are:");
|
|
int n = 1;
|
|
while (count < 20)
|
|
{
|
|
int d = countDivisors(n);
|
|
if (d > maxDiv)
|
|
{
|
|
printf("%d ", n);
|
|
maxDiv = d;
|
|
count++;
|
|
}
|
|
n++;
|
|
}
|
|
io::println("");
|
|
return 0;
|
|
} |