# Goldbach’s conjecture states that Every even integer greater than 2 is the sum

Posted: January 3rd, 2023

Place your order now for a similar assignment and have exceptional work written by our team of experts, At affordable rates

Goldbach’s conjecture states that
Every even integer greater than 2 is the sum of two primes.
The conjecture may seem obvious, but it remains unproven more than 350 years after Goldbach proposed it.
By contrast, an odd integer may or may not be the sum of two primes. For example, 9 = 2 + 7, but it is not possible to write 11 as the sum of two primes.
For any integer N ≥ 0, let g(N) be the number of ways in which N can be written as a sum of two primes P + Q, where P ≤ Q. For example:
g(1) = 0
g(3) = 0
g(4) = 1, since 4 = 2 + 2
g(5) = 1, since 5 = 2 + 3
g(10) = 2, since 10 = 3 + 7 or 10 = 5 + 5
g(11) = 0
g(22) = 3, since 22 = 3 + 19 or 22 = 5 + 17 or 22 = 11 + 11
g(24) = 3, since 24 = 5 + 19 or 24 = 7 + 17 or 24 = 11 + 13
Write a program that reads a single line containing a series of non-negative integers, separated by spaces. The program should write a single line containing g(N) for each number N in the input.
There could be hundreds of numbers in the input, and some of them may be as large as 1,000,000.
input
1 2 4 8 16 32
output
0 0 1 1 2 2
When N is odd, you can compute g(N) quick.
When you compute g(N), if you iterate over all possible pairs of primes that are less than N and check whether each pair adds up to N, that will be much too slow. Instead, iterate over all possible pairs of numbers that add up to N, and check whether each member of the pair is prime.
You will need some fast way to determine whether any of these numbers are prime. If you test each number for primality individually, your program will be too slow and you won’t pass all the tests.

### Expert paper writers are just a few clicks away

Place an order in 3 easy steps. Takes less than 5 mins.

## Calculate the price of your order

You will get a personal manager and a discount.
We'll send you the first draft for approval by at
Total price:
\$0.00