I'm need to use the Goldbach Conjecture to write a program that gets an even number greater than 2 from the user, that checks to make sure it's even and greater than two, and then finds two prime numbers that sum to the user's number. I've tried so many different ways, but I just can't seem to get it. I know how to do the first part, but it's the part where you need to find two prime numbers that sum up to the user's number that I can't get.
Please, if you could help I would very much appreciate it. Here's the part that actually works:

while True:
    numb = raw_input('Input an even number, greater than 2, or press Q to end: ')
    if numb == 'q':
        print 'end.'
        break
    if numb == 'Q':
        print 'end.'
        break
    else:
        number = int(num)
    if number<3 or number%2 != 0:
        print 'That is not greater than 2 and even, try again.'
        continue

(I don't need any fixes on this part)

Recommended Answers

All 2 Replies

Then generate primes, produce squares of them and then check through squared_primes in loop if number - squared_prime is in squared_primes.

not square, but plain primes, sorry.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.