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.

A291592 Number of bases for which 2^n-1 is a repdigit with at least 3 digits.

Original entry on oeis.org

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
Offset: 1

Views

Author

Michel Marcus, Aug 27 2017

Keywords

Examples

			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.
		

Crossrefs

Programs

  • 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 *)
  • 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

Extensions

a(63)-a(72) from Michael S. Branicky, May 28 2021