OFFSET
1,6
LINKS
David A. Corneth, Table of n, a(n) for n = 1..10000
FORMULA
a(n) = A039997(prime(n)).
a(n) <= A039994(n). - Charles R Greathouse IV, Apr 22 2015
a(n) = A079066(n) + 1. - Alois P. Heinz, Jul 29 2025
EXAMPLE
a(26) = 1 since the only prime substring of "101" is 101.
a(48) = 4 since the only distinct prime substrings of "223" are 2, 3, 23, 223. - David A. Corneth, Jul 06 2020
MAPLE
a:= n-> (s-> nops(select(t -> t[1]<>"0" and isprime(parse(t)),
{seq(seq(s[i..j], i=1..j), j=1..length(s))})))(""||(ithprime(n))):
seq(a(n), n=1..105); # Alois P. Heinz, Jul 29 2025
MATHEMATICA
f[n_] := Block[{id = IntegerDigits@ Prime@n, len = Floor[ Log[10, Prime@n] + 1]}, Count[ PrimeQ@ Union[ FromDigits@# & /@ Flatten[ Table[ Partition[id, k, 1], {k, len}], 1]], True]]; Array[f, 105] (* Robert G. Wilson v, Jun 28 2010 *)
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
a(n)=#dp(prime(n)) \\ Charles R Greathouse IV, Apr 22 2015
(Python)
from sympy import isprime, prime
def a(n):
s = str(prime(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)))
print([a(n) for n in range(1, 106)]) # Michael S. Branicky, Jul 01 2026
CROSSREFS
KEYWORD
nonn,base
AUTHOR
EXTENSIONS
Name corrected by David A. Corneth, Jul 06 2020
STATUS
approved
