33 lines
447 B
C
33 lines
447 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <limits.h>
|
|
|
|
static int
|
|
isPrime(long number)
|
|
{
|
|
if (number <= 1)
|
|
return 0;
|
|
for (long i = 2; i * i <= number; i++)
|
|
if (number % i == 0)
|
|
return 0;
|
|
return 1;
|
|
}
|
|
|
|
int
|
|
main(void)
|
|
{
|
|
int primeCount = 0;
|
|
for(long i = 0; i < LONG_MAX; i++)
|
|
{
|
|
if (isPrime(i))
|
|
{
|
|
primeCount++;
|
|
if (primeCount == 10001)
|
|
{
|
|
printf("The 10,001st prime is %ld\n", i);
|
|
exit(EXIT_SUCCESS);
|
|
}
|
|
}
|
|
}
|
|
}
|