Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # find the 2 prime numbers to equal
- # the even number to prove Goldbach's conjecture
- # Goldbach's conjecture states if you add two different prime numbers
- # together it will be equal to an even number
- # for this program we will only print out even numbers between 4 and 98
- def divisors(num):
- count = 1
- div = 2
- while (div < num):
- if (num % div == 0):
- count = count + 1
- div = div + 1
- return count
- x = 1
- prime_numbers_one = []
- prime_numbers_two = []
- while (x <= 100):
- result = divisors(x)
- if (result == 1 and x != 1):
- prime_numbers_one = prime_numbers_one + [x]
- prime_numbers_two = prime_numbers_two + [x]
- x = x + 1
- z = 4
- x = 0
- y = 0
- should_restart = True
- while should_restart:
- should_restart = False
- for x, y in [(x, y) for x in prime_numbers_one for y in prime_numbers_two]:
- if (x + y == z):
- print "prime number", x, "plus prime number", y, "equals", z
- z = z + 2
- if (z > 98):
- quit()
- should_restart = True
- break
Advertisement
Add Comment
Please, Sign In to add comment