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

I just finished Problem Set 1A but I think I am using way too much code to solve the problem. Is there anyone who can check my code and give me some advice. Thnx in advance!!

OpenStudy (anonymous):

Here is the code:

OpenStudy (anonymous):

OP, would you mind pasting your code at pastebin or codepad and linking it here? It is easier to read it like that, so it is easier for us to help you out.

OpenStudy (anonymous):

Looks fine to me. The only thing I did to check it out was to add a print statement on line 15 after the if results == 0: print candidate, just to see it was producing the primes. The only one not there is 2 which you could just add as a print "2", up front. One thing you should do is to think how to make it work for any number of primes desired. That way you could use it in a function in the future. Another thing to consider is what if someone wants primes between two numbers. say primes above 23 but below 87

OpenStudy (anonymous):

Thnx for the reply !! And BMP I will look into paste bin and codepad ...didn't hear about it before.

OpenStudy (anonymous):

The link to my code in code pad : http://codepad.org/sWly91HM Thnx again !!

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!