#
#Name: Product of Prime
#Author: Douglas Welcome
#Date: 1/3/11
#Objectives of the program: Compare the product of primes<n to e**n, or rather the sum of the logs of primes less that n to n
#
from math import *
number=3 #start with 3 because we know 2 is prime
divisor=2
counter=1#start with count=1 because 2 is already prime
sumoflog=log(2)#starts with log(2) because we assumed it was prime
userstring=raw_input("Please try a number in this magic equation machine:")#lets the user decide the number
print "You are caculating all primes less than", userstring + ". The highest prime found was:"
usernumber=int(userstring)
while number<usernumber: #this calculates to whatever the user decides n to be
if number%divisor!=0: #this tests if the number has an even remainder
if divisor<(number): #this works through the possible divisors from 2 to the number being tested
divisor+=1
if divisor>=(number): #once the divisor reaches the number being tested...
sumoflog+=log(number)
number+=2 #adds two to the number to keep going through odd numbers
divisor=2 #resets divisor
counter+=1 #advances the counter because the number is prime
else:
number+=2 #the number is not prime, advances to next odd number and resets divisor
divisor=2
answer=number-2 #because 2 was added to the prime, we have to subtract 2 to get the answer
print answer #prints answer
print "The sum of the logs is:", sumoflog
print "The ratio of sum of logs of the primes to the prime chosen is:", sumoflog/answer