OFFSET
0,1
LINKS
Rémy Sigrist, Table of n, a(n) for n = 0..10000
EXAMPLE
For n = 258:
- we have:
b 258 in base b Nonincreasing?
- ------------- --------------
2 100000010 No
3 100120 No
4 10002 No
5 2013 No
6 1110 Yes
- so a(258) = 6.
MATHEMATICA
Table[k=1; While[AnyTrue[Differences@IntegerDigits[n, ++k], #>0&]]; k, {n, 0, 100}] (* Giorgos Kalogeropoulos, Jun 02 2021 *)
PROG
(PARI) a(n) = { for (b=2, oo, my (d=digits(n, b)); if (d==vecsort(d, , 4), return (b))) }
(Python) # with library / without (faster for large n)
from sympy.ntheory import digits
def is_nondec(n, b): d = digits(n, b)[1:]; return d == sorted(d)[::-1]
def is_nondec(n, b):
if n < b: return True
n, r = divmod(n, b)
while n >= b:
(n, r), lastd = divmod(n, b), r
if r < lastd: return False
return n >= r
def a(n):
for b in range(2, n+3):
if is_nondec(n, b): return b
print([a(n) for n in range(86)]) # Michael S. Branicky, Jun 01 2021
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, Jun 01 2021
STATUS
approved