login
Number of primes less than 10^n that do not contain the string n.
0

%I #36 Jul 06 2023 09:33:17

%S 0,4,22,102,903,6310,46706,266823,2774348,16531372,419285780,

%T 3698719206,33962823012

%N Number of primes less than 10^n that do not contain the string n.

%e When n = 1, there are four primes less than 10: 2, 3, 5, and 7. None of these have 1 as a digit so a(1) = 4.

%t f[n_] := Block[{i}, Flatten@ Map[Length, Last@ Reap@ For[i = 0, i <= n, i++, Sow@ Select[Range[10^i], PrimeQ@ # && DigitCount[#][[i]] == 0 &]], {2}]]; f@ 7 (* _Michael De Vlieger_, Mar 26 2015 *)

%o (Sage) [len([p for p in prime_range(10^n) if not(str(n) in str(p))]) for n in [1..9]] # _Tom Edgar_, Feb 17 2015

%o (Python)

%o from sympy import primerange

%o def a(n):

%o target = str(n)

%o return sum(1 for p in primerange(1, 10**n) if target not in str(p))

%o print([a(n) for n in range(7)]) # _Michael S. Branicky_, Oct 30 2022

%Y Cf. A006880.

%K nonn,base,more

%O 0,2

%A _Asa Kaplan_, Feb 09 2015

%E a(7)-a(9) from _Tom Edgar_, Feb 17 2015

%E a(10) from _Michael S. Branicky_, Oct 30 2022

%E a(11) from _Michael S. Branicky_, Jun 01 2023

%E a(12) from _Michael S. Branicky_, Jul 06 2023