Goldbach's Conjecture
InterviewTime limit1sMemory limit128 MB
For each even n below 2^15, count the unordered pairs of primes that sum to n, stopping at a terminating 0.
- Level
Easy3 of 10
- Topics
- Number theory, Math, Brute force, Implementation
- Solved
- No attempts yet
Problem
It is conjectured that every even number that is at least 4 can be written as the sum of two prime numbers and :
This conjecture has been neither proven nor disproven. Even so, for any given even number you can search directly for such prime pairs and count them.
Several even numbers are given as input. For each one, write a program that outputs the number of prime pairs satisfying the condition above. Count only essentially different pairs: and are considered the same pair and must not be counted twice.
Input
Each line contains a single integer. Every integer is even and satisfies . The end of the input is indicated by the number .
Output
For each even number, output the number of prime pairs satisfying the condition, one per line. No other characters should appear in the output.