OFFSET
0,2
LINKS
Robert G. Wilson v, Table of n, a(n) for n = 0..38
Carlos Rivera, Puzzle 265. Primes embedded, The Prime Puzzles & Problems Connection.
FORMULA
EXAMPLE
For example: a(5) = 137 because 137 is the earliest number that has embedded 5 distinct primes: 3, 7, 13, 37 & 137.
MATHEMATICA
f[n_] := Block[{id = IntegerDigits@ n, lst, len}, len = Length@ id; lst = FromDigits@# & /@ Flatten[ Table[ Take[id, {i, j}], {i, 1, len}, {j, i, len}], 1]; Count[ PrimeQ@ Union@ lst, True]] (* after David W. Wilson in A039997 *); t[_] := 0; t[1] = 2; k = 1; While[k < 10000000001, a = f@ k; If[ t[a] == 0, t[a] = k; Print[{a, k}]]; k += 2]; t /@ Range[0, 28] (* Robert G. Wilson v, Apr 10 2024 *)
PROG
(PARI) dp(n)=if(n<12, return(if(isprime(n), [n], []))); my(v=vecsort(select(isprime, eval(Vec(Str(n)))), , 8), t); while(n>9, if(gcd(n%10, 10)>1, n\=10; next); t=10; while((t*=10)<n*10, if(isprime(n%t), v=concat(v, n%t))); v=vecsort(v, , 8); n\=10); v
print1(1); r=0; for(n=1, 1e6, t=#dp(n); if(t>r, r=t; print1(", "n))) \\ Charles R Greathouse IV, Jul 10 2012
(Python)
from sympy import isprime
from itertools import count, islice
def A039997(n):
s = str(n)
ss = (int(s[i:j]) for i in range(len(s)) for j in range(i+1, len(s)+1))
return len(set(k for k in ss if isprime(k)))
def agen():
adict, n = dict(), 0
for k in count(1):
v = A039997(k)
if v not in adict: adict[v] = k
while n in adict: yield adict[n]; n += 1
print(list(islice(agen(), 14))) # Michael S. Branicky, Aug 07 2022
CROSSREFS
KEYWORD
base,nonn
AUTHOR
Carlos Rivera, Apr 24 2004
EXTENSIONS
Name clarified, offset corrected, and a(9) inserted by Michael S. Branicky, Aug 07 2022
a(22) inserted and a(30)-a(38) added by Robert G. Wilson v, Apr 10 2024
STATUS
approved