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.

A258915 The number of n-digit near-repdigit primes (A164937).

Original entry on oeis.org

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

Views

Author

Robert G. Wilson v, Jun 14 2015

Keywords

Comments

The average is 44.25 with a standard deviation of about 9.48 for the first 1000 terms.
First occurrence of 20 < k < 80: 1132, ??22??, 1304, 433, 141, 181, 19, 118, 31, 253, 357, 137, 25, 68, 7, 29, 23, 10, 44, 5, 43, 16, 4, 11, 14, 3, 22, 33, 8, 139, 82, 12, 6, 102, 48, 27, 18, 36, 270, 198, 42, 54, 498, 90, 30, 738, 72, 222, 192, 852, 84, 342, ??73??, 66, ??75??, 816, 264, ??78??, 298; where ??xx?? denotes an unknown value for the index xx.
Roughly speaking, the probability that a random n-digit number is prime is about 1/(n*log(10)). The number of near-repdigit n-digit numbers is 81*n. Therefore it would be reasonable to expect around 81/log(10) (about 35) primes for each n. - Giovanni Resta, Jun 19 2015

Examples

			a(1) & a(2) = 0 by definition.
a(3) = 46 since there are 46 terms of 3 digits, see A164937(1) - A164937(46).
		

Crossrefs

Cf. A164937.
Essentially the same as A385280 but excluding near-repunit primes of A004022.

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