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

Hi folks, I am working through problem set 1b. I don't understand the math we are required to implement. Can someone link me to an example of how to sum logs? Specifically, are we to find the natural log of each prime number and add it to the sum of the previous log(prime) results, then divide the final sum by n (assuming n is the nth prime)? Thanks!

OpenStudy (anonymous):

i just read through problem set 1 for this course (introduction to computer science and programming) and it doesnt mention logs at all?

OpenStudy (anonymous):

You will want to use loops to get your answer, I used nested loops The inner loop will want to be months in a year (loop through 12 times) before going to outer loop. Outer loop is there to increase the min payment. This is using the exhaustive enumeration (small increments until you find an answer that is good enough). An answer that is good enough is when the min payment makes balance less than zero. If you would like any help with this let me know. I am struggling a little on ps2

OpenStudy (anonymous):

To sum the logs of 2 numbers, x and y, use code along the lines of log(x) + log(y). If you want to add another log to a variable tracking the current sum (which you should do), you should have something in your code along the lines of: flCurrLogSum = flCurrLogSum + log(intCurPrime) where flCurrLogSum is a float variable holding the current sum of your logs of primes and intCurPrime is the current prime number in your loop.

OpenStudy (anonymous):

ronin did you solve the first problem in that set?

OpenStudy (anonymous):

I did solve it and I didn't use logs. Maybe read the solution of the first problem ? Like quickly read it because you might be doing something different than what's asked ?

OpenStudy (anonymous):

So what, it's good for learning ;) checkthis out : fsum

OpenStudy (anonymous):

and ofc, log

OpenStudy (anonymous):

http://docs.python.org/2/library/math.html

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!