Challenge: Goldbach Conjecture
A prime number is a whole number, greater than 1, that can only be divided by itself and the number 1. It is known that all even numbers between 4 and 300,000,000,000,000,000 are equal to the sum of two primes (a fact that is believed to be true for all larger even numbers as well, and called the Goldbach Conjecture).
For example, 30 = 7 + 23. There are two other ways of expressing 30 as the sum of two primes, which are 11 + 19 and 13 + 17. These are the only ways of expressing 30 as the sum of two primes, since the order of the numbers in the additions does not matter.
- Write a program which inputs a single even number (between 4 and 10,000 inclusive) and outputs a single number which is the number of different ways the input can be expressed as the sum of two primes.
- There are four ways of expressing 46 as the sum of two primes. What are they?
- There are many odd numbers which cannot be expressed as the sum of two primes. How many such numbers are there between 4 and 50?
This question was taken from the 2008 British Informatics Olympiad.
If you can't program, there is no reason you can't attempt questions 2 and 3.
Good luck and have fun.
"Computer science is no more about computers than astronomy is about telescopes."
~ Edsger W. Dijkstra
I wrote up some python code for this. Here it is:
my answers to the questions are also on this.
That one guy that's always on