Problem 60965. List the near-square primes, p = n² + 1 (Landau's 4th problem)

Historical context
At the 1912 International Congress of Mathematicians, Edmund Landau listed four basic problems about prime numbers. These problems were characterised in his speech as "unattackable at the present state of mathematics" and are now known as Landau's problems (source : Wiki)
Problem statement
The 4th Landau's problem aalso known as the 'near square primes' asked whether there are infinitely many primes which are of the form . Your task here is to list such primes below a given input integer m.
Examples
  • m = 20 => p = [2, 5, 17] ;
  • m = 200 => p = [2, 5, 17, 37, 101, 197] ;
  • m = 2000 => p = [2, 5, 17, 37, 101, 197, 257, 401, 577, 677, 1297, 1601] ;
Fobidden functions
  • regexp
  • str2num
  • assignin
  • echo
See also

Solution Stats

82.93% Correct | 17.07% Incorrect
Last Solution submitted on Aug 18, 2025

Problem Comments

Solution Comments

Show comments

Problem Recent Solvers16

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!