A326775 For any n >= 0, let b >= 2 be the smallest base where n has all digits equal, say to d; a(n) = d.
0, 1, 2, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 3, 1, 2, 1, 2, 1, 4, 1, 2, 3, 4, 1, 3, 1, 4, 3, 2, 5, 4, 1, 2, 3, 1, 1, 2, 1, 4, 5, 2, 1, 6, 1, 5, 3, 4, 1, 6, 5, 4, 1, 2, 1, 6, 1, 2, 1, 4, 5, 6, 1, 4, 3, 7, 1, 6, 1, 2, 5, 4, 7, 6, 1, 2, 3, 2, 1, 7, 1, 2
Offset: 0
Examples
For n = 45: - we have: b 45 in base b Repdigit ? - ------------ ---------- 2 101101 no 3 1200 no 4 231 no 5 140 no 6 113 no 7 63 no 8 55 yes, with d = 5 - hence a(45) = 5.
Links
- David A. Corneth, Table of n, a(n) for n = 0..9999
Programs
-
PARI
a(n) = for (b=2, oo, if (#Set(digits(n,b))<=1, return (n%b)))
-
Python
# with library / without (faster for large n) from sympy.ntheory import digits def is_repdigit(n, b): return len(set(digits(n, b)[1:])) == 1 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): for b in range(2, n+3): if is_repdigit(n, b): return n%b print([a(n) for n in range(87)]) # Michael S. Branicky, May 31 2021
Comments