%I #24 Aug 09 2022 17:13:15
%S 0,1,1,0,1,0,1,0,0,0,1,1,2,0,1,0,2,0,1,1,1,1,3,1,2,1,2,1,2,1,2,2,1,1,
%T 2,1,3,1,1,0,1,1,2,0,1,0,2,0,0,1,1,2,3,1,1,1,2,1,2,0,1,1,1,0,1,0,2,0,
%U 0,1,2,2,3,1,2,1,1,1,2,0,0,1,2,0,1,0,1,0,1,0,0,1,1,0,1,0,2,0,0,0,1,1,2,0,1
%N Number of distinct primes which occur as substrings of the digits of n.
%H Reinhard Zumkeller, <a href="/A039997/b039997.txt">Table of n, a(n) for n = 1..10000</a>
%F a(A062115(n)) = 0; a(A093301(n)) = n and a(m) <> n for m < A093301(n). - _Reinhard Zumkeller_, Jul 16 2007
%F a(A163753(n)) > 0; a(A205667(n)) = 1. [_Reinhard Zumkeller_, Jan 31 2012]
%e a(22) = 1 because 22 has two substrings which are prime but they are identical. a(103) = 2, since the primes 3 and 103 occur as substrings.
%p a:= n-> (s-> nops(select(t -> t[1]<>"0" and isprime(parse(t)),
%p {seq(seq(s[i..j], i=1..j), j=1..length(s))})))(""||n):
%p seq(a(n), n=1..100); # _Alois P. Heinz_, Aug 09 2022
%t a[n_] := Block[{s = IntegerDigits[n], c = 0, d = {}}, l = Length[s]; t = Flatten[ Table[ Take[s, {i, j}], {i, 1, l}, {j, i, l}], 1]; k = l(l + 1)/2; While[k > 0, If[ t[[k]][[1]] != 0, d = Append[d, FromDigits[ t[[k]] ]]]; k-- ]; Count[ PrimeQ[ Union[d]], True]]; Table[ a[n], {n, 1, 105}]
%o (Haskell)
%o import Data.List (isInfixOf)
%o a039997 n = length [p | p <- takeWhile (<= n) a000040_list,
%o show p `isInfixOf` show n]
%o a039997_list = map a039997 [1..]
%o -- _Reinhard Zumkeller_, Jan 31 2012
%o (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
%o a(n)=#dp(n) \\ _Charles R Greathouse IV_, Jul 10 2012
%o (Python)
%o from sympy import isprime
%o def a(n):
%o s = str(n)
%o ss = (int(s[i:j]) for i in range(len(s)) for j in range(i+1, len(s)+1))
%o return len(set(k for k in ss if isprime(k)))
%o print([a(n) for n in range(1, 106)]) # _Michael S. Branicky_, Aug 07 2022
%Y Different from A039995 after the 100th term. Cf. A035232.
%K nonn,base
%O 1,13
%A _David W. Wilson_
%E Edited by _Robert G. Wilson v_, Feb 24 2003