%I #13 Jun 02 2021 22:14:07
%S 2,2,2,2,2,4,2,2,2,3,4,5,2,3,2,2,2,5,3,6,4,3,3,5,2,3,3,3,2,7,2,2,2,6,
%T 6,6,3,4,7,3,3,4,4,6,7,7,7,7,2,7,5,8,4,4,3,5,2,4,4,8,2,4,2,2,2,9,3,3,
%U 9,9,9,10,3,8,9,3,3,9,3,3,3,3,10,10,4,4
%N a(n) is the least base k >= 2 that the base-k digits of n are nonincreasing.
%H Rémy Sigrist, <a href="/A344887/b344887.txt">Table of n, a(n) for n = 0..10000</a>
%F a(n) <= A000196(n) + 2.
%F a(n) <= 10 for any n in A009996.
%F a(n) = 2 iff n belongs to A023758.
%e For n = 258:
%e - we have:
%e b 258 in base b Nonincreasing?
%e - ------------- --------------
%e 2 100000010 No
%e 3 100120 No
%e 4 10002 No
%e 5 2013 No
%e 6 1110 Yes
%e - so a(258) = 6.
%t Table[k=1;While[AnyTrue[Differences@IntegerDigits[n,++k],#>0&]];k,{n,0,100}] (* _Giorgos Kalogeropoulos_, Jun 02 2021 *)
%o (PARI) a(n) = { for (b=2, oo, my (d=digits(n, b)); if (d==vecsort(d,,4), return (b))) }
%o (Python) # with library / without (faster for large n)
%o from sympy.ntheory import digits
%o def is_nondec(n, b): d = digits(n, b)[1:]; return d == sorted(d)[::-1]
%o def is_nondec(n, b):
%o if n < b: return True
%o n, r = divmod(n, b)
%o while n >= b:
%o (n, r), lastd = divmod(n, b), r
%o if r < lastd: return False
%o return n >= r
%o def a(n):
%o for b in range(2, n+3):
%o if is_nondec(n, b): return b
%o print([a(n) for n in range(86)]) # _Michael S. Branicky_, Jun 01 2021
%Y Cf. A000196, A009996, A023758, A273040.
%K nonn,base
%O 0,1
%A _Rémy Sigrist_, Jun 01 2021