A258915 The number of n-digit near-repdigit primes (A164937).
0, 0, 46, 43, 40, 53, 35, 49, 40, 38, 44, 52, 35, 45, 49, 42, 38, 57, 27, 45, 38, 47, 37, 52, 33, 45, 56, 38, 36, 65, 29, 56, 48, 40, 38, 58, 37, 33, 57, 40, 37, 61, 41, 39, 37, 44, 36, 55, 47, 43, 47, 43, 35, 62, 43, 46, 29, 35, 37, 56, 39, 41, 46, 48, 39, 74, 45, 34, 34, 35, 34, 67
Offset: 1
Keywords
Examples
a(1) & a(2) = 0 by definition. a(3) = 46 since there are 46 terms of 3 digits, see A164937(1) - A164937(46).
Links
- Robert G. Wilson v, Table of n, a(n) for n = 1..1532
Crossrefs
Programs
-
Mathematica
f[n_] := Block[{lst = {}, r = (10^(n - 1) - 1)/9}, Do[ AppendTo[ lst, DeleteCases[ Select[ FromDigits[ Permutations[ Append[ IntegerDigits[ a*r], d]]], PrimeQ@# && # > 100 &], r]], {a, 9}, {d, 0, 9}]; Length@ Union@ Flatten@ lst](* adapted after Arkadiusz Wesolowski of A164937 *) Array[f, 70] (* to view the terms assign the terms in the b-file to "lst" and then *) ListPlot@ Sort@ lst (* and/or *) g[n_] := Count[lst, n]; DiscretePlot[ g[n], {n, 23, 80}]
-
Python
from gmpy2 import is_prime, digits def a(n): if n < 3: return 0 Rn = (10**n-1)//9 return len(set(t for d in range(1, 10) for i in range(n if d in {1, 3, 7, 9} else 1) for c in set(range(-d, 10-d))-{0} if len(digits(t:=d*Rn+c*10**i))==n and is_prime(t))) print([a(n) for n in range(1, 73)]) # Michael S. Branicky, Jun 28 2025
Comments