Problem 60940. Find the first occurence of a given gap between two consecutive prime numbers

Problem statement
Given a gap Δ= p' - p between the two consecutive prime numbers p and p', find its first occurence, f.
Examples
  • If , f=2, since 5 - 3 = 2, and 3 is the 2nd prime;
  • If , f=4, since 11 - 7 = 4, and 7 is the 4th prime;
  • If , f=9, since 29 - 23 = 6, and 23 is the 9th prime;
If Δ neither equals an even positive integer nor equals 1 your function should return the empty set : f = [];
See also

Solution Stats

41.67% Correct | 58.33% Incorrect
Last Solution submitted on Aug 17, 2025

Problem Comments

Solution Comments

Show comments

Problem Recent Solvers17

Suggested Problems

More from this Author42

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!