Goldbach Partitions
Time limit3sMemory limit64 MB
Count the pairs of primes that sum to each given even number up to ten million.
- Level
Medium4 of 10
- Topics
- Number theory, Math
- Solved
- No attempts yet
Problem
Goldbach's conjecture is one of the oldest unsolved problems in mathematics. It claims that every even integer greater than can be written as the sum of two primes. An even number written as such a sum is called a Goldbach partition of that number. Two sums that use the same pair of primes in a different order are the same partition, so and count once.
Here are a few even numbers with all of their Goldbach partitions.
So has one partition, has two, and has six. Count the Goldbach partitions of every even number you are given.
Input
Each line of the input holds one even integer (). A line holding marks the end of the input and is not a query.
Output
For each even number in the input, print the number of its Goldbach partitions on its own line, in input order.