prime number

question:

By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6^(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

posted under , |

0 comments:

Newer Post Older Post Home

About Me

My photo
Hi everyone,myself Alagappan...electronic and communication engg. student... living in madurai... interested in everything... want to achieve something great in my lifetime...

Followers


Recent Comments