%I #103 Apr 08 2024 18:53:58
%S 1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
%T 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
%U 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3
%N Number of digits in the decimal expansion of n.
%C From _Hieronymus Fischer_, Jun 08 2012: (Start)
%C For n > 0 the first differences of A117804.
%C The total number of digits necessary to write down all the numbers 0, 1, 2, ..., n is A117804(n+1). (End)
%C Here a(0) = 1, but a different common convention is to consider that the expansion of 0 in any base b > 0 has 0 terms and digits. - _M. F. Hasler_, Dec 07 2018
%H Charles R Greathouse IV, <a href="/A055642/b055642.txt">Table of n, a(n) for n = 0..10000</a>
%F a(A046760(n)) < A050252(A046760(n)); a(A046759(n)) > A050252(A046759(n)). - _Reinhard Zumkeller_, Jun 21 2011
%F a(n) = A196563(n) + A196564(n).
%F a(n) = 1 + floor(log_10(n)) = 1 + A004216(n) = ceiling(log_10(n+1)) = A004218(n+1), if n >= 1. - _Daniel Forgues_, Mar 27 2014
%F a(A046758(n)) = A050252(A046758(n)). - _Reinhard Zumkeller_, Jun 21 2011
%F a(n) = A117804((n+1) - A117804(n), n > 0. - _Hieronymus Fischer_, Jun 08 2012
%F G.f.: g(x) = 1 + (1/(1-x))*Sum_{j>=0} x^(10^j). - _Hieronymus Fischer_, Jun 08 2012
%F a(n) = A262190(n) for n < 100; a(A262198(n)) != A262190(A262198(n)). - _Reinhard Zumkeller_, Sep 14 2015
%e Examples:
%e 999: 1 + floor(log_10(999)) = 1 + floor(2.x) = 1 + 2 = 3 or
%e ceiling(log_10(999+1)) = ceiling(log_10(1000)) = ceiling(3) = 3;
%e 1000: 1 + floor(log_10(1000)) = 1 + floor(3) = 1 + 3 = 4 or
%e ceiling(log_10(1000+1)) = ceiling(log_10(1001)) = ceiling(3.x) = 4;
%e 1001: 1 + floor(log_10(1001)) = 1 + floor(3.x) = 1 + 3 = 4 or
%e ceiling(log_10(1001+1)) = ceiling(log_10(1002)) = ceiling(3.x) = 4;
%p A055642 := proc(n)
%p max(1,ilog10(n)+1) ;
%p end proc: # _R. J. Mathar_, Nov 30 2011
%t Join[{1}, Array[ Floor[ Log[10, 10# ]] &, 104]] (* _Robert G. Wilson v_, Jan 04 2006 *)
%t Join[{1},Table[IntegerLength[n],{n,104}]]
%t IntegerLength[Range[0,120]] (* _Harvey P. Dale_, Jul 02 2016 *)
%o (PARI) a(n)=#Str(n) \\ _M. F. Hasler_, Nov 17 2008
%o (PARI) A055642(n)=logint(n+!n,10)+1 \\ Increasingly faster than the above, for larger n. (About twice as fast for n ~ 10^7.) - _M. F. Hasler_, Dec 07 2018
%o (Haskell)
%o a055642 :: Integer -> Int
%o a055642 = length . show -- _Reinhard Zumkeller_, Feb 19 2012, Apr 26 2011
%o (Magma) [ #Intseq(n): n in [0..105] ]; // _Bruno Berselli_, Jun 30 2011
%o (Common Lisp) (defun A055642 (n) (if (zerop n) 1 (floor (log n 10)))) ; _James Spahlinger_, Oct 13 2012
%o (Python)
%o def a(n): return len(str(n))
%o print([a(n) for n in range(121)]) # _Michael S. Branicky_, May 10 2022
%o (Python)
%o def A055642(n): # Faster than len(str(n)) from ~ 50 digits on
%o L = math.log10(n or 1)
%o if L.is_integer() and 10**int(L)>n: return int(L or 1)
%o return int(L)+1 # _M. F. Hasler_, Apr 08 2024
%Y Cf. A043537, A178788, A046034, A019546, A054899, A122840, A055640, A055641, A102669-A102685, A117804, A160093, A160094, A196563, A196564, A000120, A000788, A023416, A059015 (for base 2).
%Y Cf. A262190, A262198.
%Y Cf. A007953: sum of digits.
%K base,easy,nonn,nice
%O 0,11
%A _Henry Bottomley_, Jun 06 2000
|