Challenge: Goldbach Conjecture  

  RSS

2

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.

  1. 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.
  2. There are four ways of expressing 46 as the sum of two primes. What are they?
  3. 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.
Louis

"Computer science is no more about computers than astronomy is about telescopes."
~ Edsger W. Dijkstra

 
1

Solution:-

This is my code:
https://github.com/ldhmachin/BIO-2008-Goldbach/

This is the answer to Question 2.

This is the answer to Question 3.

"Computer science is no more about computers than astronomy is about telescopes."
~ Edsger W. Dijkstra

 
1

I wrote up some python code for this. Here it is:

https://docs.google.com/document/d/1RWe35UXM9NO-iuRX0MhgTTQ6vAQoNXQyA0MaRcKULUY/edit

my answers to the questions are also on this.

That one guy that's always on

Looks good Lucas!

Share:
  
Working

Please Login or Register