Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 39 Online
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
Sarahr6767: Can anyone help me with math
3 hours ago 5 Replies 1 Medal
Sarahr6767: Can anyone help me with math
4 hours ago 0 Replies 0 Medals
Countless7Echos: uuhh update: pushing to another project yayyy (simplified artstyle)
2 hours ago 5 Replies 0 Medals
Nina001: I need tips on how to let go and not hurt yourself
5 hours ago 48 Replies 2 Medals
Taku12: Any other tips for my art project?
3 hours ago 10 Replies 0 Medals
mintyy: where and how can i get sub?
6 hours ago 15 Replies 2 Medals
EdwinJsHispanic: THIS IS FOR EXOTIC
8 hours ago 20 Replies 6 Medals
breiadabrattzz: I need help to make a theme -
1 day ago 14 Replies 3 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!