Problem 155721 · medium · Level 01 Prerequisites & Setup

Goldbach Pair

functions · primes · tuples

Goldbach's conjecture says every even number greater than 2 is the sum of two primes. Write goldbach_pair(n) that returns the pair (p, q) with p + q == n, both prime, p <= q, and p as small as possible.

Examples

Input:  n = 4
Output: (2, 2)

Input:  n = 10
Output: (3, 7)

Input:  n = 28
Output: (5, 23)

Constraints

  • 4 <= n <= 10**6, n is even

Goals

  • Search for the first value that satisfies two conditions
  • Return a pair of related values
Starting Python…