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

Could someone take a look at my code for ps1b? Thanks.

OpenStudy (anonymous):

Here is the solution I came up with. It works, but for numbers above 20,000 or so, it can take a little while to compute the answer. I was just wondering if there's a better/faster way to do it? from math import * n = input('Pick a number: ') sum = 0 for number in range(2,n): divisor = 2 while (divisor < (number/2)) and (number % divisor !=0): divisor = divisor + 1 if number % divisor != 0: prime_number = number sum = sum + log(prime_number) print sum + log(2) print n print (sum/n)

OpenStudy (anonymous):

Here is all the code, highlighted with comments, if you need it: http://dpaste.com/hold/450061/

OpenStudy (anonymous):

Last line, use this : print ((sum+log(2))/n) If not, you are not counting the log of 2 in your ratio and your theorem fails

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!
Latest Questions
Arriyanalol: i need help
1 day ago 7 Replies 1 Medal
Arriyanalol: CONGRATS to me
1 day ago 8 Replies 2 Medals
Legomaster346: What colleges are good that are near Arab Alabama?
1 week ago 5 Replies 0 Medals
Arriyanalol: i need help
1 week ago 6 Replies 2 Medals
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!