A069749 Number of primes less than 10^n containing only the digits 2 and 3 (A020458).
2, 3, 5, 7, 11, 18, 31, 44, 83, 135, 239, 436, 818, 1436, 2773, 4695, 9244, 17022, 32948, 58158, 116040, 214188, 423902, 791950, 1554834, 2904470, 5725780, 10536383, 21070698, 40748211, 79634658, 148530950, 296094802, 561919901
Offset: 1
Programs
-
Mathematica
s = 0; Do[k = 0; While[k < 2^n, k++; If[p = FromDigits[ PadLeft[ IntegerDigits[k, 2], n] + 2]; PrimeQ[p], s++ ]]; Print[s], {n, 1, 22}] With[{c=Select[Flatten[Table[FromDigits/@Tuples[{2,3},n],{n,22}]], PrimeQ]}, Table[Count[c,?(#<10^i&)],{i,22}]] (* _Harvey P. Dale, Mar 18 2016 *)
-
Python
from sympy import isprime from itertools import count, islice, product def agen(): # generator of terms c = 2 for d in count(2): yield c for first in product("23", repeat=d-1): t = int("".join(first) + "3") if isprime(t): c += 1 print(list(islice(agen(), 20))) # Michael S. Branicky, May 23 2024
Extensions
a(23)-a(27) from Sean A. Irvine, May 17 2024
a(28)-a(34) from Michael S. Branicky, May 22 2024
Comments