【题目】
【答案】本题答案为 104743。
By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.
What is the 10 001st prime number?
【翻译】
前六个质数是2,3,5,7,11和13,其中第6个是13.
第10001个质数是多少?
【思路】简单题 不解释【代码】
bool isPrime( int value)
{
if(value==2)
return true;
if(value<2 || (!(value&1)))
return false;
for(int i=2;i<(int)sqrt(value)+1;i++)
{
if(value%i==0)
{
return false;
}
}
return true;
}
void test7()
{
int count=0;
int i;
for( i=2;;i++)
{
if(isPrime(i))
count++;
if(count==10001)
break;
}
cout<<i<<endl;
}
【答案】本题答案为 104743。