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

http://codepad.org/fZHWhfpc this is what I would turn in as PS1 problem 1. Now on to problem 2. C&C please

OpenStudy (anonymous):

Looks good! Only critique is that your primality test counts 0 and 1 as prime: see http://codepad.org/Ttw7jBKx Doesn't really matter for the problem but something to consider.

OpenStudy (anonymous):

I guess you could in force that "n" can't equal 0 or 1--or must strictly start at 2 (since its the first prime), but definitely a good first start. How would you enforce "n" being 2 or != 0 or 1?

OpenStudy (anonymous):

before your "for x in range (2, int(math.sqrt(n)) + 1):" statement, you could include: if n < 2: return False

OpenStudy (anonymous):

Then 2 and three wouldn't show up on the list. I would say that this program as it is would get 100%--unless the professors like to nitpick

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!