I am trying to complete an assignment for my beginner's computer science. I have to write a program that proves that every even number greater than four is the sum of two prime numbers. I prompt the user for the top end of the range (the lowest being four) and then prove Goldbach's theory. However, I have to determine which numbers of the factoring are prime in another function. Here is what I have so far:
import sys
def main():
print "This program will verify Goldbach's Conjecture from 4 to a number of your choosing."
num = input("What should the top end of the range be? ")
findPrimeAddends(num)
def isPrime(n):
for n in range(4,int(num**0.5)+1):
if(num % n == 0):
return False
return True,0
def findPrimeAddends(num):
for n in range(4, num + 1):
x = n/2
(a,b) = isPrime(n)
if(a > b):
sys.stdout.write("%d = %d + %d\n" % (x,a,b))
main()
Right now, I keep getting an error because I haven't defined "num" in the isPrime function. Can anyone help me out?