A load-testing tool splits n virtual users into two groups, and for its hashing scheme both group sizes must be prime numbers. n is even and at least 4.
Write primeSplit(n) that returns [p, q] with p and q prime, p <= q, and p + q === n. If several pairs work, return the one with the smallest p. (Every even n from 4 up to the constraint has such a pair.)
Input: n = 10 Output: [3,7]
3 + 7 = 10 and 5 + 5 = 10 both work. 3 is the smaller first part.
Input: n = 4 Output: [2,2]
2 + 2 is the only split.
4 <= n <= 10^6n is even.Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #639 Split Into Two Prime Groups. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.