Problems > Goldbach Split

Goldbach Split

Difficulty: 1400 3000 ms 128 MB

math number-theory

Every even N ≥ 4 (in this range) can be written as a sum of two primes. Print the split with the smallest first prime.

Input: one even integer N.

Output: two primes p q with p + q = N and p minimal.

Constraints:

  • 4 ≤ N ≤ 107
  • N is even

Sample Tests

Input 1
10
Output 1
3 7
Input 2
4
Output 2
2 2

Read the Editorial

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.