### prime number

**question:**

By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6

What is the 1001

#include

void main()

{

long int i,j,prime,count=0;

clrscr();

for(i=2;i<10000;i++)

{

prime=1;

for(j=2;j<=i/2;j++)

{

if(i%j==0)

{

prime=0;

}

}

if(prime==1)

{

count=count+1;

if(count==1001)

{

printf("%ld is prime\n",i);

break;

}

}

}

printf("count is %ld",count);

getch();

}

answer:7927

^{th}prime is 13.What is the 1001

^{st}prime number?**answer:****#include**#include

void main()

{

long int i,j,prime,count=0;

clrscr();

for(i=2;i<10000;i++)

{

prime=1;

for(j=2;j<=i/2;j++)

{

if(i%j==0)

{

prime=0;

}

}

if(prime==1)

{

count=count+1;

if(count==1001)

{

printf("%ld is prime\n",i);

break;

}

}

}

printf("count is %ld",count);

getch();

}

answer:7927

## 0 comments:

Post a Comment