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-2 of 2 results.

A039995 Number of distinct primes which occur as subsequences of the sequence of 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, 2, 1, 3, 0, 1
Offset: 1

Views

Author

Keywords

Comments

a(n) counts subsequences of digits of n which denote primes.

Examples

			a(103) = 3; the 3 primes are 3, 13 and 103.
		

Crossrefs

A039997 counts only the primes which occur as substrings, i.e. contiguous subsequences. Cf. A035232.
Cf. A010051.

Programs

  • Haskell
    import Data.List (subsequences, nub)
    a039995 n = sum $
       map a010051 $ nub $ map read (tail $ subsequences $ show n)
    -- Reinhard Zumkeller, Jan 31 2012
    
  • Mathematica
    cnt[n_] := Module[{d = IntegerDigits[n]}, Length[Union[Select[FromDigits /@ Subsets[d], PrimeQ]]]]; Table[cnt[n], {n, 105}] (* T. D. Noe, Jan 31 2012 *)
  • Python
    from sympy import isprime
    from itertools import chain, combinations as combs
    def powerset(s): # nonempty subsets of s
        return chain.from_iterable(combs(s, r) for r in range(1, len(s)+1))
    def a(n):
        ss = set(int("".join(s)) for s in powerset(str(n)))
        return sum(1 for k in ss if isprime(k))
    print([a(n) for n in range(1, 106)]) # Michael S. Branicky, Aug 07 2022

Formula

a(A094535(n)) = n and a(m) < n for m < A094535(n); A039995(39467139) = 100, cf. A205956. - Reinhard Zumkeller, Feb 01 2012

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
Showing 1-2 of 2 results.