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

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

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

A168169 Primes with d digits (d>0) which have more than 2d distinct primes as substrings.

Original entry on oeis.org

23719, 31379, 52379, 113171, 113173, 113797, 123719, 153137, 179719, 199739, 211373, 213173, 229373, 231197, 231379, 233113, 233713, 236779, 237331, 237619, 237971, 241973, 259397, 291373, 313739, 317971, 327193, 337397, 343373, 353173
Offset: 1

Views

Author

M. F. Hasler, Nov 28 2009

Keywords

Comments

"Substrings" includes the whole number in itself.
This is a subsequence of A168167.
The least palindrome in this sequence is 9179719.

Examples

			The least number with d digits to have over 2d distinct prime substrings is the prime a(1)=23719, with 5 digits and #{2, 3, 7, 19, 23, 37, 71, 719, 2371, 3719, 23719} = 11.
		

Crossrefs

Programs

  • Maple
    filter:= proc(n) local i,j,count,d,S,x,y;
      if not isprime(n) then return false fi;
      d:= ilog10(n)+1;
      count:= 0; S:= {};
      for i from 0 to d-1 do
        x:= floor(n/10^i);
        for j from i to d-1 do
          y:= x mod 10^(j-i+1);
          if not member(y,S) and isprime(y) then count:= count+1; S:= S union {y}; if count > 2*d then return true fi fi
      od od;
      false
    end proc:
    select(filter, [seq(i,i=1..10^6,2)]); # Robert Israel, Nov 11 2020
  • PARI
    {forprime( p=1, default(primelimit), #prime_substrings(p) > #Str(p)*2 & print1(p", "))} /* see A168168 for prime_substrings() */
Showing 1-3 of 3 results.