The Great Prime Gap
MediumAcc. 93.1%
+30 XP 12
Primality Voids
A prime gap is the difference between two successive prime numbers. Example: Primes 7 and 11. Gap = 4.
The Assignment
Your function receives parameters start and end.
- Loop through the range. Identify all primes.
- Track the maximum difference between two consecutive primes found.
- Print the maximum gap size.
01EXAMPLE 1
Input
start=1, end=10Output
2Explanation: Primes {2,3,5,7}. Max gap is 2.
Constraints
- Correct primality test.
- If fewer than 2 primes exist, return 0.
MathLoops
JavaScriptSystem handles I/O — write your function only
Loading...
3 Hidden
Input Arguments
start1
end10
Expected Output
2
Click RUN to test your solution