|
|
A291592
|
|
Number of bases for which 2^n-1 is a repdigit with at least 3 digits.
|
|
1
|
|
|
0, 0, 1, 1, 2, 2, 1, 2, 2, 2, 1, 4, 2, 2, 3, 3, 1, 4, 1, 4, 3, 2, 1, 6, 2, 2, 3, 4, 1, 6, 1, 4, 3, 2, 3, 7, 1, 2, 3, 6, 1, 6, 1, 4, 5, 2, 1, 8, 2, 4, 3, 4, 1, 6, 3, 6, 3, 2, 1, 10, 1, 2, 5, 5, 3, 6, 1, 4, 3, 6, 1, 10
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,5
|
|
LINKS
|
|
|
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))
(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
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn,more
|
|
AUTHOR
|
|
|
EXTENSIONS
|
|
|
STATUS
|
approved
|
|
|
|