2
$\begingroup$

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 10001st prime number?

  • 3
    This is Project Euler problem 7: http://projecteuler.net/index.php?section=problems&id=72010-10-29
  • 0
    Yes! and I would like to know how to solve this.2010-10-29
  • 8
    Just compute the first 10001 primes...2010-10-29
  • 1
    You might want to look at the prime counting function.2010-10-29

3 Answers 3

4

It is 104743, according to http://primes.utm.edu/lists/small/100000.txt and the related list of the first 10,000 primes ;-)

  • 1
    while true, this answer does not help in the spirit of Project Euler where this question originates from. OTOH, it *is* the answer, so +1. Mentioning the 10.000 list is a good hint indeed.2010-10-29
3

I assume you want to program this? Then the question belongs in a CS forum. However, I will try to motivate how to program this using properties of prime numbers:

1) For a number you could try to divide it by every single positive integer smaller than the respective number (except for 1). This is stupid, as you obviously could just search through the odd numbers (checking 2 first). But can you do even better?

2) Do you have to stop at n-1, or can you stop way earlier? You can. Find out where.

Now count primes.

  • 1
    I'd joke that the OP should try sieving, but s/he might take that seriously...2010-10-29
  • 1
    @J. M.: Why is that a joke? For a small number like 10,001 this is probably the fastest approach.2010-10-29
  • 1
    I think he meant by hand.2010-10-30
0
#include 
#include 

main()
{
    int n,l,h,x,y,p,q;
    printf("enter a number:");
    scanf("%d",&n);
    l=low(n);
    h=high(n);
    q=l-h;
    x=n-l;
    y=h-n;
    p=x-y;

    if(q==0)
        printf("\n This is prime number:%d",n);
    else if(p==0)
        printf("\n The nearest prime numbers are:\n%d\n%d",l,h);
    else if(x0;i--)
 {
     k=0;
     for(j=1;j<=i;j++)
     {
         if(i%j==0)
         {
             k++;               
         }    
     }
     if(k==2)
     {
         //printf("%d",i);
         break;
     }

 }
  return i;
}