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

8 years ago
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

8 years ago
Can't find your answer? Make a FREE account and ask your own question, OR you can help others and earn volunteer hours!
Latest Questions
nikkixmarie: bio help with plants
17 minutes ago 0 Replies 0 Medals
misty34: Second opinion? I think the answer is B??
3 hours ago 1 Reply 0 Medals
Wermin: mi
3 hours ago 0 Replies 0 Medals
misty34: Can you give me recipes to try?? I want to try some new foods.
2 hours ago 16 Replies 7 Medals
Kabbed: animeghoul help me please
4 hours ago 2 Replies 1 Medal