Skip to content

Instantly share code, notes, and snippets.

@rcanand
Created June 5, 2017 16:27
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
from sympy import sieve
def goldbach():
'''
For each even number > 2,
it finds a pair of two primes that add up to the number
'''
even = 4
while(True):
printed = False
if sieve._list[-1] < even:
sieve.extend(even * 2)
for a in sieve._list:
for b in sieve._list:
if a + b == even:
print('{} = {} + {}'.format(even, a, b))
even += 2
printed = True
break
if printed:
break
if not printed:
print('{} is a counterexample!'.format(even))
break
if __name__ == '__main__':
goldbach()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment