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.

  1. Loop through the range. Identify all primes.
  2. Track the maximum difference between two consecutive primes found.
  3. Print the maximum gap size.

01EXAMPLE 1

Inputstart=1, end=10
Output2

Explanation: Primes {2,3,5,7}. Max gap is 2.

Constraints

  • Correct primality test.
  • If fewer than 2 primes exist, return 0.
MathLoops
JavaScript
Loading...
3 Hidden

Input Arguments

start1
end10

Expected Output

2

Click RUN to test your solution