The Goldbach Triple
HardAcc. 76.4%
+45 XP 25
The Odd Balance
Goldbach's Weak Conjecture states that every odd integer greater than 5 is the sum of three primes. Example: $7 = 2 + 2 + 3$. $9 = 3 + 3 + 3$.
The Assignment
Your function receives an odd parameter num.
- Use triple-nested loops (
i, j, k) to search for three prime numbers. - Ensure
i + j + k === num. - To avoid duplicates, find the first set where
i <= j <= k. - Print the result: "num = i + j + k" and break.
01EXAMPLE 1
Input
num = 7Output
7 = 2 + 2 + 3Explanation: All factors are prime.
Constraints
- Triple-nested search loop.
- Correct primality tests.
MathLoops
JavaScriptSystem handles I/O — write your function only
Loading...
2 Hidden
Input Arguments
num7
Expected Output
7 = 2 + 2 + 3
Click RUN to test your solution