← Back to challenges

Add up to Even Number with Primes

JavaScriptHardmathnumbersarrays

Instructions

Create a function that takes an even number (will always be greater than 4) and return an array of all pairs of prime numbers which add up to the given number.

Examples

primePairArr(10) ➞ ["3+7", "5+5"]

primePairArr(50) ➞ ["3+47", "7+43", "13+37", "19+31"]

primePairArr(100) ➞ ["3+97", "11+89", "17+83", "29+71", "41+59", "47+53"]

Notes

N/A

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.