cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

Showing 1-5 of 5 results.

A094535 a(n) is the smallest integer m such that A039995(m)=n.

Original entry on oeis.org

1, 2, 13, 23, 113, 131, 137, 1013, 1031, 1273, 1237, 1379, 6173, 10139, 10193, 10379, 10397, 10937, 12397, 12379, 36137, 36173, 101397, 102371, 101937, 102973, 103917, 106937, 109371, 109739, 123797, 123917, 123719, 346137, 193719, 346173
Offset: 0

Views

Author

Farideh Firoozbakht, May 08 2004

Keywords

Examples

			a(6) = 137 because 137 is the smallest number m such that A039995(m) = 6; the six numbers 3, 7, 13, 17, 37 & 137 are primes.
See also A205956 for a(100) = 39467139.
		

Crossrefs

Programs

  • Haskell
    import Data.List (elemIndex)
    import Data.Maybe (fromJust)
    a094535 n = a094535_list !! n
    a094535_list = map ((+ 1) . fromJust . (`elemIndex` a039995_list)) [0..]
    -- Reinhard Zumkeller, Feb 01 2012
    
  • Mathematica
    cnt[n_] := Count[ PrimeQ@ Union[ FromDigits /@ Subsets[ IntegerDigits[n]]], True]; a[n_] := Block[{k = 1}, While[cnt[k] != n, k++]; k]; Array[a, 21, 0] (* Giovanni Resta, Jun 16 2017 *)
  • Python
    from sympy import isprime
    from itertools import chain, combinations as combs, count, islice
    def powerset(s): # nonempty subsets of s
        return chain.from_iterable(combs(s, r) for r in range(1, len(s)+1))
    def A039995(n):
        ss = set(int("".join(s)) for s in powerset(str(n)))
        return sum(1 for k in ss if isprime(k))
    def agen():
        adict, n = dict(), 0
        for k in count(1):
            v = A039995(k)
            if v not in adict: adict[v] = k
            while n in adict: yield adict[n]; n += 1
    print(list(islice(agen(), 36))) # Michael S. Branicky, Aug 07 2022

Formula

A039995(a(n)) = n and A039995(m) != n for m < a(n). - Reinhard Zumkeller, Feb 01 2012

A035232 Number of substrings of n which are primes (counted with multiplicity).

Original entry on oeis.org

0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 2, 0, 1, 0, 2, 0, 1, 1, 1, 2, 3, 1, 2, 1, 2, 1, 2, 1, 2, 2, 2, 1, 2, 1, 3, 1, 1, 0, 1, 1, 2, 0, 1, 0, 2, 0, 0, 1, 1, 2, 3, 1, 2, 1, 2, 1, 2, 0, 1, 1, 1, 0, 1, 0, 2, 0, 0, 1, 2, 2, 3, 1, 2, 1, 2, 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
Offset: 1

Views

Author

Keywords

Comments

No leading 0's allowed in substrings.

Examples

			The primes occurring as substrings of 37 are 3, 7, 37, so a(37) = 3.
a(22) = 2, since the prime 2 occurs twice as a substring.
		

Crossrefs

Programs

  • 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 07 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[d], True]]; Table[ a[n], {n, 1, 105}]
  • Python
    from sympy import isprime
    def a(n):
        s = str(n)
        ss = (s[i:j] for i in range(len(s)) for j in range(i+1, len(s)+1))
        return sum(1 for w in ss if w[0] != "0" and isprime(int(w)))
    print([a(n) for n in range(1, 106)]) # Michael S. Branicky, Aug 07 2022

Formula

Trivial upper bound: a(n) <= binomial(floor(log(n)/log(10)+2), 2) ~ k*log^2 n with k = 0.09430584850580... = 1/log(10)^2/2. - Charles R Greathouse IV, Nov 15 2022

Extensions

Edited by Robert G. Wilson v, Feb 24 2003

A039997 Number of distinct primes which occur as substrings of the digits of n.

Original entry on oeis.org

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
Offset: 1

Views

Author

Keywords

Examples

			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.
		

Crossrefs

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

Programs

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

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]

Extensions

Edited by Robert G. Wilson v, Feb 24 2003

A205956 Distinct primes occurring as not necessarily consecutive subsequences in decimal representation of 39467139.

Original entry on oeis.org

3, 7, 13, 19, 31, 37, 41, 43, 47, 61, 67, 71, 73, 79, 97, 139, 313, 347, 349, 367, 373, 379, 397, 419, 439, 461, 463, 467, 479, 613, 619, 673, 719, 739, 919, 941, 947, 967, 971, 3413, 3461, 3463, 3467, 3469, 3613, 3671, 3673, 3719, 3739, 3919, 3943, 3947
Offset: 1

Views

Author

Reinhard Zumkeller, Feb 02 2012

Keywords

Comments

39467139 is the smallest number containing exactly 100 primes: A094535(100) = 39467139, A039995(39467139) = 100; 39467139 itself is not prime: 39467139 = 3*53*89*2789.

Examples

			a(10) = 61        <- ___6_1__;
a(20) = 367       <- 3__67___;
a(30) = 613       <- ___6_13_;
a(40) = 3413      <- 3_4__13_;
a(50) = 3919      <- 39___1_9;
a(60) = 9419      <- _94__1_9;
a(70) = 9719      <- _9__71_9;
a(80) = 39439     <- 394___39;
a(90) = 346139    <- 3_46_139;
a(100) = 3946139  <- 3946_139.
		

Crossrefs

Cf. A010051.

Programs

  • Haskell
    import Data.List (subsequences, nub, sort)
    a205956 n = a205956_list !! (n-1)
    a205956_list = sort $ filter ((== 1) . a010051) $
                          nub $ map read (tail $ subsequences "39467139")

A039994 Number of primes embedded in decimal expansion of prime(n) as substrings.

Original entry on oeis.org

1, 1, 1, 1, 1, 2, 2, 1, 3, 2, 2, 3, 1, 2, 2, 3, 2, 1, 2, 2, 3, 2, 2, 1, 2, 2, 3, 3, 2, 4, 4, 5, 6, 4, 2, 3, 4, 3, 4, 6, 5, 2, 3, 4, 5, 2, 3, 4, 3, 3, 4, 5, 3, 3, 4, 4, 3, 4, 3, 2, 5, 5, 4, 4, 4, 6, 3, 4, 5, 2, 4, 4, 5, 5, 5, 3, 3, 5, 2, 1, 3, 3, 5, 3, 3, 3, 1, 4, 3, 3, 4, 4, 3, 2, 1, 4, 3, 3, 6, 3, 4, 3, 4, 3, 4
Offset: 1

Views

Author

Keywords

Examples

			a(26) = 2 since prime(26) = 101 and "101" has two prime subsequences, 101 and 11.
		

Crossrefs

Cf. A039995.
Different from A039996.

Formula

a(n) = A039995(prime(n)).

Extensions

Definition and example clarified by N. J. A. Sloane, Jun 03 2024
Showing 1-5 of 5 results.