Consider the sequence that begins 101, 113, 127, 131, 149, 151, 163,... Not only is every term prime, the nth term is the smallest prime with n in the interior digits.
Write a function that takes an integer and returns the smallest prime with that integer in its interior.
Although it's not part of the problem, you might think about these questions and others: Which terms are formed by adding 1s to the beginning and end? Which value of n results in a prime that requires more than one digit added to beginning and end? Does the sequence include any terms starting and ending with 9?

Solution Stats

38 Solutions

19 Solvers

Last Solution submitted on May 25, 2026

Last 200 Solutions

Problem Comments

Solution Comments

Show comments
Loading...

Problem Recent Solvers19

Suggested Problems

More from this Author324

Problem Tags

Community Treasure Hunt

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

Start Hunting!