Problem 60975. Check Legendre's conjecture

Context and problem statement
Legendre's conjecture states for a given positive integer n, there always exists at least one prime number p between and (n+1²) :
For a given input n, List the prime number(s) p in the interval ]n^2; (n+1)^2[.
Examples
  • n = 1 => p = [2, 3];
  • n = 2 => p = [5, 7];
  • n = 10 => p = [101, 103, 107, 109, 113];
  • n = 20 => p = [401, 409, 419, 421, 431, 433, 439];
Forbidden functions / expressions
  • regexp
  • assignin
  • str2num
  • echo
See also

Solution Stats

88.89% Correct | 11.11% Incorrect
Last Solution submitted on Aug 18, 2025

Problem Comments

Solution Comments

Show comments

Problem Recent Solvers15

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!