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

i need help with problem set 1 b!!! anyone??? :) tx

OpenStudy (anonymous):

This is what i got. Any comments? from math import * prime_candidate = 3 divisor = 2 prime_number = 2 given_number = 10000 partial_sum = log(2) print "2 is prime number 1" while prime_candidate <= given_number: while prime_candidate%divisor != 0: divisor=divisor+1 if divisor == prime_candidate: print prime_candidate, 'is prime' partial_sum = partial_sum + log(prime_candidate) prime_candidate = prime_candidate+2 divisor=2 else: prime_candidate = prime_candidate+2 divisor=2 else: print partial_sum, 'is the sum of all the logarithms of the' 'prime numbers between 2 and', given_number, print 'the previous sum.' print 'divided by', given_number ,'equals', partial_sum/given_number

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
klmjnmkj: math problem
13 minutes ago 5 Replies 1 Medal
klmjnmkj: math problem
22 minutes ago 9 Replies 1 Medal
SunnyLandscape04: This goes under Politics but, what are your ideas on Biden, and racism? (do not f
26 minutes ago 21 Replies 3 Medals
katelyn865: whats the coolst thing you evey seen
1 hour ago 9 Replies 2 Medals
vybez: help ;o
1 hour ago 19 Replies 1 Medal
kristiannnnnt: What's your average WPM?
1 hour ago 0 Replies 0 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!