A091637 Number of primes less than 10^n which do not contain the digit 3.
3, 16, 102, 668, 4715, 34813, 265015, 2067152, 16413535, 132200223, 1076692515, 8849480283, 73288053795, 610860050965
Offset: 1
Examples
a(2)=16 because there are 25 primes less than 10^2, 9 have at least one digit 3; 25-9 = 16.
Programs
-
Mathematica
NextPrim[n_] := Block[{k = n + 1}, While[ !PrimeQ[k], k++ ]; k]; c = 0; p = 1; Do[ While[ p = NextPrim[p]; p < 10^n, If[ Position[ IntegerDigits[p], 3] == {}, c++ ]]; Print[c]; p--, {n, 1, 8}] (* Robert G. Wilson v, Feb 02 2004 *) Table[Count[Prime[Range[PrimePi[10^n]]],?(DigitCount[#,10,3]==0&)],{n,8}] (* _Harvey P. Dale, Oct 04 2011 *)
-
PARI
good(n)=n=eval(Vec(Str(n)));for(i=1,#n,if(n[i]==3,return(1)));0 a(n)=my(s);forprime(p=2,10^n,s+=good(p));s \\ Charles R Greathouse IV, Oct 04 2011
-
Python
from sympy import primerange def a(n): return sum('3' not in str(p) for p in primerange(2, 10**n)) print([a(n) for n in range(1, 7)]) # Michael S. Branicky, Mar 16 2021
Extensions
Edited and extended by Robert G. Wilson v, Feb 02 2004
a(9)-a(12) from Donovan Johnson, Feb 14 2008
a(13) from Robert Price, Nov 08 2013
a(14) from Giovanni Resta, Mar 20 2017
Comments