Goldbach's Conjecture
InterviewTime limit0.5sMemory limit256 MB
For each even n up to one million, find the split into two odd primes with the largest difference, printing n = a + b.
- Level
Medium4 of 10
- Topics
- Number theory, Math, Brute force, Implementation
- Solved
- No attempts yet
Problem
In 1742, the German amateur mathematician Christian Goldbach sent a letter to Leonhard Euler proposing the following conjecture.
Every even number greater than 4 can be written as the sum of two odd prime numbers.
For example, , and both 3 and 5 are odd primes. Likewise, and .
This conjecture remains unproven to this day.
Write a program that verifies this conjecture for every even number up to one million.
Input
The input consists of one or more test cases. The number of test cases does not exceed 100,000.
Each test case consists of a single even integer ().
The last line of the input contains a single , which marks the end of the input.
Output
For each test case, print the result in the form , where and are odd primes. The numbers and the operator are separated by a single space. If there are several ways to express as a sum of two odd primes, print the one for which is the largest. If cannot be written as the sum of two odd primes, print Goldbach's conjecture is wrong.