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.

A039995 Number of distinct primes which occur as subsequences of the sequence of digits of n.

This page as a plain text file.
%I A039995 #25 Aug 08 2022 08:24:04
%S A039995 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,
%T A039995 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,
%U A039995 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
%N A039995 Number of distinct primes which occur as subsequences of the sequence of digits of n.
%C A039995 a(n) counts subsequences of digits of n which denote primes.
%H A039995 Reinhard Zumkeller, <a href="/A039995/b039995.txt">Table of n, a(n) for n = 1..10000</a>
%F A039995 a(A094535(n)) = n and a(m) < n for m < A094535(n); A039995(39467139) = 100, cf. A205956. - _Reinhard Zumkeller_, Feb 01 2012
%e A039995 a(103) = 3; the 3 primes are 3, 13 and 103.
%t A039995 cnt[n_] := Module[{d = IntegerDigits[n]}, Length[Union[Select[FromDigits /@ Subsets[d], PrimeQ]]]]; Table[cnt[n], {n, 105}] (* _T. D. Noe_, Jan 31 2012 *)
%o A039995 (Haskell)
%o A039995 import Data.List (subsequences, nub)
%o A039995 a039995 n = sum $
%o A039995    map a010051 $ nub $ map read (tail $ subsequences $ show n)
%o A039995 -- _Reinhard Zumkeller_, Jan 31 2012
%o A039995 (Python)
%o A039995 from sympy import isprime
%o A039995 from itertools import chain, combinations as combs
%o A039995 def powerset(s): # nonempty subsets of s
%o A039995     return chain.from_iterable(combs(s, r) for r in range(1, len(s)+1))
%o A039995 def a(n):
%o A039995     ss = set(int("".join(s)) for s in powerset(str(n)))
%o A039995     return sum(1 for k in ss if isprime(k))
%o A039995 print([a(n) for n in range(1, 106)]) # _Michael S. Branicky_, Aug 07 2022
%Y A039995 A039997 counts only the primes which occur as substrings, i.e. contiguous subsequences. Cf. A035232.
%Y A039995 Cf. A010051.
%K A039995 nonn,base
%O A039995 1,13
%A A039995 _David W. Wilson_