login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 59th year, we have over 358,000 sequences, and we’ve crossed 10,300 citations (which often say “discovered thanks to the OEIS”).

Other ways to Give
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A039997 Number of distinct primes which occur as substrings of the digits of n. 12
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, 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, 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 (list; graph; refs; listen; history; text; internal format)
OFFSET

1,13

LINKS

Reinhard Zumkeller, Table of n, a(n) for n = 1..10000

FORMULA

a(A062115(n)) = 0; a(A093301(n)) = n and a(m) <> n for m < A093301(n). - Reinhard Zumkeller, Jul 16 2007

a(A163753(n)) > 0; a(A205667(n)) = 1. [Reinhard Zumkeller, Jan 31 2012]

EXAMPLE

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.

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))})))(""||n):

seq(a(n), n=1..100); # Alois P. Heinz, Aug 09 2022

MATHEMATICA

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}]

PROG

(Haskell)

import Data.List (isInfixOf)

a039997 n = length [p | p <- takeWhile (<= n) a000040_list,

show p `isInfixOf` show n]

a039997_list = map a039997 [1..]

-- Reinhard Zumkeller, Jan 31 2012

(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(n) \\ Charles R Greathouse IV, Jul 10 2012

(Python)

from sympy import isprime

def a(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)))

print([a(n) for n in range(1, 106)]) # Michael S. Branicky, Aug 07 2022

CROSSREFS

Different from A039995 after the 100th term. Cf. A035232.

Sequence in context: A113686 A193403 A354272 * A039995 A035232 A359269

Adjacent sequences: A039994 A039995 A039996 * A039998 A039999 A040000

KEYWORD

nonn,base

AUTHOR

David W. Wilson

EXTENSIONS

Edited by Robert G. Wilson v, Feb 24 2003

STATUS

approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified January 1 03:21 EST 2023. Contains 359177 sequences. (Running on oeis4.)