Can Even Numbers Be Written as the Sum of Two Primes?

  • MHB
  • Thread starter Ackbach
  • Start date
  • Tags
    2015
In summary, the Goldbach's Conjecture states that every even number greater than 2 can be expressed as the sum of two prime numbers. However, this has not been proven and is still a topic of ongoing mathematical research. There is no known pattern or formula for prime numbers that can be summed to get an even number, making it difficult to prove the conjecture. Although no exceptions have been found, it cannot be definitively stated that there are none without a proof. The Goldbach's Conjecture is significant as one of the oldest and most famous unsolved problems in mathematics, with applications in number theory and cryptography. While progress has been made towards proving it, a definitive proof has not yet been found and the conjecture
  • #1
Ackbach
Gold Member
MHB
4,155
89
Here is this week's POTW:

-----

Write a computer program in Python or R to check, given a particular even integer, whether it can be written as the sum of two primes. (N.B., that this can be done for all even numbers greater than $2$ is the famous unproven Goldbach Conjecture.) The output should include a boolean: true if it can be done, and false if it cannot. If it can be done, output the two odd primes that sum to the input.

-----

Remember to read the http://www.mathhelpboards.com/showthread.php?772-Problem-of-the-Week-%28POTW%29-Procedure-and-Guidelines to find out how to http://www.mathhelpboards.com/forms.php?do=form&fid=2!
 
Physics news on Phys.org
  • #2
So, ahem, Bacterius was supposed to solve this one, since he solved POTW # 164 - a highly related problem. But no one solved this week's POTW. I cobbled together this solution from Baterius's solution to POTW # 164 plus a tad bit more extra code I found and tweaked on the Internet. No doubt there are much more efficient methods of solution. For one, the sieve of Eratosthenes should be used to generate an array of prime numbers smaller than the input even number. Then you loop through that. Probably much more efficient for large input numbers. Still, this code runs quite fast up to $10^{11}$.

Code:
#!/usr/bin/env python3

# A primality test, following Ackbach's precise specifications.

class Result:
    def __init__(self, IsPrime, Error):
        self.IsPrime = IsPrime
        self.Error = Error

    @staticmethod
    def Error(msg):
        return Result(None, msg)

    @staticmethod
    def IsPrime():
        return Result(True, "")

    @staticmethod
    def IsNotPrime():
        return Result(False, "")

    def __repr__(self):
        return '(IsPrime={0}, Error="{1}")'.format(self.IsPrime,
                                                   self.Error)

def is_prime(n):
    if not isinstance(n, int):
        return Result.Error("an informative error message")

    if n <= 0:
        return Result.Error("a suitable error message")

    if n == 2:
        return Result.IsPrime()
    elif n == 1 or n % 2 == 0:
        return Result.IsNotPrime()
    else:
        divisor = 3

        while divisor * divisor <= n:
            if n % divisor == 0:
                return Result.IsNotPrime()
            else:
                divisor += 2

        return Result.IsPrime()

def findGolCon(num):
    answer1 = num // 2
    if is_prime(answer1).IsPrime:
        return answer1, answer1
    else:
        answer2 = answer1
        while not is_prime(answer1).IsPrime or not is_prime(answer2).IsPrime:
            answer1 -= 1
            answer2 += 1
        return answer1, answer2
 

Related to Can Even Numbers Be Written as the Sum of Two Primes?

1. Can all even numbers be written as the sum of two primes?

No, not all even numbers can be written as the sum of two primes. This is known as the Goldbach's Conjecture, which states that every even number greater than 2 can be expressed as the sum of two prime numbers. However, this has not been proven and is still a topic of ongoing mathematical research.

2. Is there a pattern in the primes that can be summed to get an even number?

No, there is no known pattern in the primes that can be summed to get an even number. This is why the Goldbach's Conjecture remains unproven, as it is difficult to find a pattern or formula for prime numbers.

3. Are there any exceptions to the Goldbach's Conjecture?

No, there are no exceptions to the Goldbach's Conjecture that have been found. Every even number that has been tested has been successfully written as the sum of two primes. However, without a proof, it cannot be definitively stated that there are no exceptions.

4. What is the significance of the Goldbach's Conjecture?

The Goldbach's Conjecture is significant because it is one of the oldest and most famous unsolved problems in mathematics. It has been studied by many mathematicians and continues to be a topic of research. It also has applications in other areas of mathematics, such as number theory and cryptography.

5. Has any progress been made towards proving the Goldbach's Conjecture?

Yes, there has been progress made towards proving the Goldbach's Conjecture. Many mathematicians have attempted to prove it, and some have even made significant progress. However, a definitive proof has not yet been found, and the conjecture remains unsolved.

Similar threads

Replies
1
Views
2K
  • Math POTW for University Students
Replies
1
Views
1K
  • Math POTW for University Students
Replies
1
Views
2K
  • Math POTW for University Students
Replies
2
Views
2K
  • Math POTW for University Students
Replies
1
Views
2K
  • Math POTW for University Students
Replies
1
Views
2K
  • Math POTW for University Students
Replies
1
Views
2K
  • Math POTW for University Students
Replies
1
Views
1K
  • Math POTW for University Students
Replies
1
Views
1K
Back
Top