Given an even number ( greater than 2 ), return two prime numbers whose sum will be equal to given number.

Problem:

Given an even number ( greater than 2 ), return two prime numbers whose sum will be equal to given number.

Example:


Input : 4
Output: 2 + 2 = 4

Solution:

This problem’s solution is straight forward.
Generate prime numbers less than N, and hash them in a list.
Then iterate on the whole list, and for every prime P, check if N-P is also prime. If you find such a pair, you are done

Leave a Reply

Your email address will not be published. Required fields are marked *