Skip to content

Practice Prime Pairs With Target Sum

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#2761
LeetCode Problem

Prime Pairs With Target Sum

Problem Statement

Return every pair of primes [x,y] with x <= y and x + y = n, sorted by x ascending. Return [] when no pair exists. A prime is greater than 1 and divisible only by itself and 1.

Source: Prime Pairs With Target Sum on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
n = 10
Output
[[3,7],[5,5]]

# Example 2

Input
n = 2
Output
[]

Constraints

1 <= n <= 10^6

Related LeetCode Problems

Practice more problems similar to Prime Pairs With Target Sum.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.