A community for students.
Here's the question you clicked on:
 0 viewing
anonymous
 5 years ago
pset 1 problem 1b. help,
Im confused, i can't understand what the problem im being asked is, i am new to programming and have not heard the log function mentioned in the lecture, am i correct in thinking that as follows
n = number entered by user,
and i need to show that,
all the primes before n, added together, divided by n**2 is less then 1, and as n increases, the answer gets closer to one. (is log another name for exponent? the e**n confused me, surley it would be n ** 2? ) thanks in advance
anonymous
 5 years ago
pset 1 problem 1b. help, Im confused, i can't understand what the problem im being asked is, i am new to programming and have not heard the log function mentioned in the lecture, am i correct in thinking that as follows n = number entered by user, and i need to show that, all the primes before n, added together, divided by n**2 is less then 1, and as n increases, the answer gets closer to one. (is log another name for exponent? the e**n confused me, surley it would be n ** 2? ) thanks in advance

This Question is Closed

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0Your program needs to accept a number n, then take the log of every prime number between 2 and n (inclusive) add up all those logs. Then display 3 things. The sum you computed, n, and the ratio of n and the sum (float(sum)/n).

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0The log function is part of the math module.

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0math.log() exists for python...it returns natural logarithm, that is e based logarithm

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0Jaymorganrice, "log" or logarithm, is the inverse of exponentiation. I suggest the Khan Academy tutorial on logarithms for further reference. http://www.khanacademy.org/video/introductiontologarithms?playlist=Prealgebra Let us not forget that math is an integral part of computer programming and science, and needs to be understood to compliment the knowledge provided here. You wouldn't attend MIT Comp Sci without having a lot of math with it. OCW doesn't make that apparent. :)

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0I have no math background, so this also confused me. Synthesetic's post and video really jogged my memory on what a logarithm was, but I still had no idea what e**n meant. Well, e is the mathmatical constant, which is the base of a natural logarithm. http://en.wikipedia.org/wiki/Logarithm "The natural logarithm uses the constant e (approximately 2.718) as its base" So e**n is 2.718**n Now this is making a lot of sense.

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0ahh i see, so is e a function already in python? or do i import it as part of the math? thanks alot for all the help, i actually got A in math but dont recall info on logarithms here in uk, although i finished school at 16 over here and didn't go to colledge as i went streight into work. thanks again for all the help

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0e is a number. log is a function. Both are available in the math module: import math print math.e print math.e * math.e # e to the power of 2 (or e**2) print log(math.e*math.e) # the log of a power of e is the exponent.

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0err the last line should be print math.log(math.e*math.e)
Ask your own question
Sign UpFind more explanations on OpenStudy
Your question is ready. Sign up for free to start getting answers.
spraguer
(Moderator)
5
→ View Detailed Profile
is replying to Can someone tell me what button the professor is hitting...
23
 Teamwork 19 Teammate
 Problem Solving 19 Hero
 Engagement 19 Mad Hatter
 You have blocked this person.
 ✔ You're a fan Checking fan status...
Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.