A381606 a(n) is the smallest prime number greater than n that contains n as a substring of its digits.
101, 11, 23, 13, 41, 53, 61, 17, 83, 19, 101, 113, 127, 113, 149, 151, 163, 173, 181, 191, 1201, 211, 223, 223, 241, 251, 263, 127, 281, 229, 307, 131, 1321, 233, 347, 353, 367, 137, 383, 139, 401, 241, 421, 431, 443, 457, 461, 347, 487, 149, 503, 151, 521, 353, 541
Offset: 0
Examples
The first prime number greater than 0 that contains "0" is 101, so a(0) = 101. The first prime number greater than 1 that contains "1" is 11, so a(1) = 11. The first prime number greater than 2 that contains "2" is 23, so a(2) = 23.
Links
- Joost de Winter, Table of n, a(n) for n = 0..9000
- David A. Corneth, PARI program
- Joost de Winter, MATLAB function
Programs
-
MATLAB
\\ See De Winter link
-
Maple
f:= proc(n) local m,d,d1,x,y,L; m:= length(n); for d from 1 do L:= sort([seq(10^d * n + x, x = 1 .. 10^d-1, 2), seq(n+10^m*x, x=10^(d-1) .. 10^d-1), seq(seq(seq(10^d1*n + x + 10^(m+d1)*y, x=1 .. 10^d1-1,2),y=10^(d-d1-1) .. 10^(d-d1)-1),d1=1..d-1)]); for x in L do if isprime(x) then return x fi od od end proc: f(0):= 101: map(f, [$0..100]); # Robert Israel, Mar 02 2025
-
Mathematica
a[n_] := Module[{p = NextPrime[n + 1], s = ToString[n]}, While[! StringContainsQ[ToString[p], s], p = NextPrime[p]]; p]; Array[a, 100, 0] (* Amiram Eldar, Mar 03 2025 *)
-
PARI
a(n) = my(p=nextprime(n+1), s=Str(n)); while (#strsplit(Str(p), s) < 2, p = nextprime(p+1)); p; \\ Michel Marcus, Mar 01 2025
-
PARI
\\ See Corneth link
Formula
a(n) > 2n. For large enough n, a(n) < n^5 by the strongest known version of Linnik's theorem. - Charles R Greathouse IV, Mar 01 2025