login
Largest digit of n.
105

%I #52 Mar 19 2023 05:01:36

%S 0,1,2,3,4,5,6,7,8,9,1,1,2,3,4,5,6,7,8,9,2,2,2,3,4,5,6,7,8,9,3,3,3,3,

%T 4,5,6,7,8,9,4,4,4,4,4,5,6,7,8,9,5,5,5,5,5,5,6,7,8,9,6,6,6,6,6,6,6,7,

%U 8,9,7,7,7,7,7,7,7,7,8,9,8,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,9,9,9,1,1,2,3,4

%N Largest digit of n.

%C A095815(n) = n + a(n). - _Reinhard Zumkeller_, Aug 23 2011

%C a(A007088(n)) = 1, n > 0; a(A136399(n)) > 1. - _Reinhard Zumkeller_, Apr 25 2012

%C a(n) = 9 for almost all n. Sum_{n < x} a(n) = 9x + O(.956^x). - _Charles R Greathouse IV_, Oct 02 2013

%H Reinhard Zumkeller, <a href="/A054055/b054055.txt">Table of n, a(n) for n = 0..10000</a>

%e a(12)=2 because 1 < 2.

%p [seq(max(convert(n,base,10)),n=0..120)];

%t f[n_] := Sort[IntegerDigits[n]][[-1]]; Array[f, 105, 0] (* _Alonso del Arte_, May 14 2011 *) (* and revised by _Robert G. Wilson v_, Aug 24 2011 *)

%t Max/@IntegerDigits[Range[0,110]] (* _Harvey P. Dale_, Apr 17 2016 *)

%o (Haskell)

%o a054055 = f 0 where

%o f m x | x <= 9 = max m x

%o | otherwise = f (max m d) x' where (x',d) = divMod x 10

%o -- _Reinhard Zumkeller_, Jun 20 2012, May 14 2011

%o (PARI) a(n)=vecmax(eval(Vec(Str(n)))) \\ _Charles R Greathouse IV_, Jun 16 2011

%o (PARI) a(n)=vecmax(digits(n)) \\ _Charles R Greathouse IV_, Oct 02 2013

%o (Magma) [n eq 0 select 0 else Maximum(Intseq(n)): n in [0..104]]; // _Bruno Berselli_, Aug 24 2011

%o (Python)

%o def A054055(n): return max(int(d) for d in str(n)) # _Chai Wah Wu_, Jun 06 2022

%Y For bases 3 through 12 see A190592, A190593, A190594, A190595, A190596, A190597, A190598, A054055, A190599, A190600.

%Y Cf. A054054.

%K base,easy,nonn,look

%O 0,3

%A _Henry Bottomley_, Apr 29 2000