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
Problem Comments
-
1 Comment
Nicolas Douillet
on 17 Jul 2025
Actually all these primes also have the form p = 4n² + 1, except 2 of course, because all these other primes are odd numbers (p = 2n + 1)
Solution Comments
Show commentsProblem Recent Solvers16
Suggested Problems
More from this Author42
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!