A community for students.
Here's the question you clicked on:
 0 viewing
anonymous
 5 years ago
Could someone take a look at my code for ps1b? Thanks.
anonymous
 5 years ago
Could someone take a look at my code for ps1b? Thanks.

This Question is Closed

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0Here is the solution I came up with. It works, but for numbers above 20,000 or so, it can take a little while to compute the answer. I was just wondering if there's a better/faster way to do it? from math import * n = input('Pick a number: ') sum = 0 for number in range(2,n): divisor = 2 while (divisor < (number/2)) and (number % divisor !=0): divisor = divisor + 1 if number % divisor != 0: prime_number = number sum = sum + log(prime_number) print sum + log(2) print n print (sum/n)

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0Here is all the code, highlighted with comments, if you need it: http://dpaste.com/hold/450061/

anonymous
 5 years ago
Best ResponseYou've already chosen the best response.0Last line, use this : print ((sum+log(2))/n) If not, you are not counting the log of 2 in your ratio and your theorem fails
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.