A community for students.

Here's the question you clicked on:

55 members online
  • 0 replying
  • 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

  • This Question is Closed
  1. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Your 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).

  2. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    The log function is part of the math module.

  3. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    logarithm i guess

  4. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    math.log() exists for python...it returns natural logarithm, that is e based logarithm

  5. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Jaymorganrice, "log" or logarithm, is the inverse of exponentiation. I suggest the Khan Academy tutorial on logarithms for further reference. http://www.khanacademy.org/video/introduction-to-logarithms?playlist=Pre-algebra 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. :)

  6. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    I 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.

  7. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    ahh 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

  8. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    e 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.

  9. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    err the last line should be print math.log(math.e*math.e)

  10. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy

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
  • 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.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.