## ECOO '07 R3 P1 - Sum of Primes

View as PDF

Points: 7
Time limit: 2.5s
Memory limit: 256M

Problem type

Any natural number can be expressed as the sum of , or odd primes. If itself is a prime, only one number is required.

However, because there are so many solutions for large composite , it is your task to find the solution where are prime, and where is as large as possible, or, if cannot be expressed as the sum of two primes, find the solution where are prime and where is as large as possible, followed by where is as large as possible.

#### Examples       is larger than and so, the required solution is .

In this case, is larger than , and so the required solution is .

The input contains numbers on separate lines. These numbers are less than and larger than . Write a program that will find the sum of primes for each of these numbers as described, and display the result as is shown in the sample below.

#### Sample Input

49
152029
90118
4565973
705510

#### Sample Output

49 = 13 + 17 + 19
152029 = 152029
90118 = 44987 + 45131
4565973 = 1521991 + 1521991 + 1521991
705510 = 352753 + 352757

• commented on July 23, 2019, 1:56 a.m.

This comment is hidden due to too much negative feedback. Show it anyway.

• commented on July 30, 2019, 2:52 p.m. edited

IIRC they proved that it holds for at least all • commented on Feb. 17, 2019, 3:28 p.m.

Shouldn't the output for 49 be: 49 = 2 + 47

If you can't express 49 as the sum of two primes, then you go on to try and find three primes. But you can find two primes. So it shouldnt be 13+17 + 19

• commented on April 21, 2017, 2:50 p.m.

for the first test case isn't it supposed to be 49 = 2 + 47

• commented on April 21, 2017, 5:59 p.m.

let the first number as large as possible

• commented on May 1, 2017, 5:43 p.m. edited

But.. the problem statement implies that you should express as a sum of three primes only if you can't express it as a sum of two primes.
IDK tho

• commented on May 1, 2017, 11:35 p.m.

Any natural number can be expressed as the sum of or odd primes.

• commented on May 2, 2017, 5:49 p.m.

lmao rip
fair enough

• commented on Aug. 26, 2018, 8:42 p.m.

This comment is hidden due to too much negative feedback. Show it anyway.

• commented on April 9, 2017, 8:42 p.m.

This comment is hidden due to too much negative feedback. Show it anyway.

• commented on April 9, 2017, 10:40 p.m. isn't a prime number, and all of , and must be prime.