Goldbach Conjecture

According to Golbach's conjecture, every even greater than 2 is the sum of two primes. Here we experimentally demonstrate that it is only true if there are infinitely many primes.

Theorem: There are infinitely many primes.

Proof: We prove this using Goldbach conjecture. Suppose a finite set of prime numbers

P = {p1, p2, …, pn}

Let n be an even number greater than 2 and less than or equal 2pn . Then there exists an n between and 2n which is not the sum of two primes from the list. In the Python code below we generate prime numbers up to 100. When the prime numbers are added element by element to get n = p1 + p2 , one might expect it will generate all even numbers between 6 and 194. Here the generated even numbers which is the sum of the odd prime. 4 is an exception which 4 = 2+2. But the following even numbers

Even number not on the list: [174, 182, 184, 188, 190, 192]

are not the sum of two primes from the list. For Goldbach conjecture to hold there must be infinitely many primes.


def sieve_of_eratosthenes(n):
    primes = [True] * (n + 1)  # Initialize a list with True values
    p = 2
    while p * p <= n:
        if primes[p] == True:
            for i in range(p * p, n + 1, p):
                primes[i] = False
        p += 1

    prime_numbers = [p for p in range(3, n + 1) if primes[p]]
    return prime_numbers

# Generate prime numbers up to n
P = sieve_of_eratosthenes(100)

print("Prime numbers:", sorted(P))
m = max(P)
B = {a + b for a in P for b in P}
C = {number for number in range(6, 2 * m) if number % 2 == 0}
D = C - B


print(C)
print("Goldbach pair:", sorted(B))
print("Even number not on the list:", sorted(D))

The output is

Prime numbers: [3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
Goldbach pair: [6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 176, 178, 180, 186, 194]
Even number not on the list: [174, 182, 184, 188, 190, 192]

Leave a comment