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

Hey... I just finished ps1 problem a. Check it out: http://dpaste.com/hold/569941/

OpenStudy (anonymous):

It's good but the problem wants you to calculate the first 1000 prime numbers, no the first prime numbers up to 1000. You need to implement a counter or something to keep track. (or just check the length of your list 'primes'

OpenStudy (anonymous):

(That is, if I'm remembering the problem correctly)

OpenStudy (anonymous):

your program is good but it takes a lot of time for computation and moreover what you are doing in this program is not what has been asked in the ps1, your program is creating a list that is taking a hell lot of time because it prints many things again and again

OpenStudy (anonymous):

Good, read VertigoJC's criticisms of what you are supposed to do. A list is a fine way, if you ask me, however, you only need print the last number as the answer, the 1000th. I'm curious how you got that formula. It obviously works, your primes are correct, but I don't understand how.

OpenStudy (anonymous):

Joz, I got the formula from wiki: http://en.wikipedia.org/wiki/Fermat_primality_test

OpenStudy (anonymous):

Thanks for pointing out what I was suppose to do. I don't know how I missed that. I just finished redoing the problem. Here is my new code revised: http://dpaste.com/570356/

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!