OFFSET
1,5
EXAMPLE
For n=3, 2^3-1 is 7; 7 is a repdigit with more than 3 digits only in base 2: 111_2. So a(3)=1.
For n=5, 2^5-1 is 31; 31 is a repdigit with more than 3 digits only in base 2 and 5: 11111_2 and 111_5 So a(5)=2.
MATHEMATICA
Table[With[{m = 2^n - 1}, Count[Range[2, Floor@ Sqrt@ m], _?(And[Length@ Union@ # == 1, Length@ # >= 3] &@ IntegerDigits[m, #] &) ]], {n, 40}] (* Michael De Vlieger, Aug 27 2017 *)
PROG
(PARI) nbr(n) = {nb = 0; fordiv(n, d, for (b=d+1, n, nd = 3; vd = [d, d, d]; while(fromdigits(vd, b) < n, nd ++; vd = vector(nd, k, d)); if ((x=fromdigits(vd, b)) == n, nb++); if ((x > n) && (nd == 3), break); ); ); nb; }
a(n) = nbr(2^n-1);
(Python)
from sympy.ntheory import count_digits
def ok(n, b): return False if n <= b**2 else len(count_digits(n, b)) == 1
def a(n): return sum(ok(2**n-1, b) for b in range(2, 2**n))
print([a(n) for n in range(1, 21)]) # Michael S. Branicky, May 27 2021
(Python) # Faster version suitable for extension
def is_repdigit(n, b):
if n < b: return True
n, r = divmod(n, b)
onlyd = r
while n > b:
n, r = divmod(n, b)
if r != onlyd: return False
return n == onlyd
def a(n):
c, target = 0, 2**n - 1
for b in range(2, 2**n):
if target < b**2: break # not 3 digits
c += is_repdigit(target, b)
return c
print([a(n) for n in range(1, 41)]) # Michael S. Branicky, May 27 2021
CROSSREFS
KEYWORD
nonn,more
AUTHOR
Michel Marcus, Aug 27 2017
EXTENSIONS
a(63)-a(72) from Michael S. Branicky, May 28 2021
STATUS
approved