answersLogoWhite

0

from math import *

def testPrime(x):

factor = 2

while factor**2 <= x:

if x % factor == 0:

return False

else:

factor = factor + 1

return True

candidate = 3

primeLogSum = log(2)

n = int(raw_input("What is n? "))

while candidate < n:

if testPrime(candidate):

primeLogSum = primeLogSum + log(candidate)

candidate = candidate + 2

print primeLogSum, n, primeLogSum/n

User Avatar

Wiki User

14y ago

Still curious? Ask our experts.

Chat with our AI personalities

ProfessorProfessor
I will give you the most educated answer.
Chat with Professor
SteveSteve
Knowledge is a journey, you know? We'll get there.
Chat with Steve
LaoLao
The path is yours to walk; I am only here to hold up a mirror.
Chat with Lao

Add your answer:

Earn +20 pts
Q: Using python how to print the sum of logs of primes?
Write your answer...
Submit
Still have questions?
magnify glass
imp