Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 17 Online
OpenStudy (anonymous):

What is the complexity of finding the 1000th prime number problem?

OpenStudy (anonymous):

I think it is P time.

OpenStudy (anonymous):

I just write a function to test if a given number a prime number,then call it in a loop to accumulate it.

OpenStudy (anonymous):

right

OpenStudy (anonymous):

http://www.cse.iitk.ac.in/users/manindra/algebra/primality_v6.pdf This paper shows that the complexity is PTIME

OpenStudy (anonymous):

so you check every prime number til the 1000th one, then accumulate it?

OpenStudy (anonymous):

Actually, I write another two functions.,one is to find the prime number not bigger than 1000,the other one to find the 1000th prime number . check then count or append it to a list.

OpenStudy (anonymous):

There's an efficient algorithm to find prime number not bigger than n: the sieve of eratosthenes (there are other sieves but the sieve of eratosthenes is probably the simplest one and still works very fast): http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes

OpenStudy (anonymous):

Here's a python implementation: http://rosettacode.org/wiki/Sieve_of_Eratosthenes#Python

OpenStudy (anonymous):

Try to get people to 'think' about the problem...not get the answer right out!!!

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!