# Greetings from The On-Line Encyclopedia of Integer Sequences! http://oeis.org/ Search: id:a055642 Showing 1-1 of 1 %I A055642 #107 Aug 14 2024 01:54:13 %S A055642 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 A055642 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 A055642 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 A055642 Number of digits in the decimal expansion of n. %C A055642 From _Hieronymus Fischer_, Jun 08 2012: (Start) %C A055642 For n > 0 the first differences of A117804. %C A055642 The total number of digits necessary to write down all the numbers 0, 1, 2, ..., n is A117804(n+1). (End) %C A055642 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 A055642 Charles R Greathouse IV, Table of n, a(n) for n = 0..10000 %F A055642 a(A046760(n)) < A050252(A046760(n)); a(A046759(n)) > A050252(A046759(n)). - _Reinhard Zumkeller_, Jun 21 2011 %F A055642 a(n) = A196563(n) + A196564(n). %F A055642 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 A055642 a(A046758(n)) = A050252(A046758(n)). - _Reinhard Zumkeller_, Jun 21 2011 %F A055642 a(n) = A117804(n+1) - A117804(n), n > 0. - _Hieronymus Fischer_, Jun 08 2012 %F A055642 G.f.: g(x) = 1 + (1/(1-x))*Sum_{j>=0} x^(10^j). - _Hieronymus Fischer_, Jun 08 2012 %F A055642 a(n) = A262190(n) for n < 100; a(A262198(n)) != A262190(A262198(n)). - _Reinhard Zumkeller_, Sep 14 2015 %e A055642 Examples: %e A055642 999: 1 + floor(log_10(999)) = 1 + floor(2.x) = 1 + 2 = 3 or %e A055642 ceiling(log_10(999+1)) = ceiling(log_10(1000)) = ceiling(3) = 3; %e A055642 1000: 1 + floor(log_10(1000)) = 1 + floor(3) = 1 + 3 = 4 or %e A055642 ceiling(log_10(1000+1)) = ceiling(log_10(1001)) = ceiling(3.x) = 4; %e A055642 1001: 1 + floor(log_10(1001)) = 1 + floor(3.x) = 1 + 3 = 4 or %e A055642 ceiling(log_10(1001+1)) = ceiling(log_10(1002)) = ceiling(3.x) = 4; %p A055642 A055642 := proc(n) %p A055642 max(1,ilog10(n)+1) ; %p A055642 end proc: # _R. J. Mathar_, Nov 30 2011 %t A055642 Join[{1}, Array[ Floor[ Log[10, 10# ]] &, 104]] (* _Robert G. Wilson v_, Jan 04 2006 *) %t A055642 Join[{1},Table[IntegerLength[n],{n,104}]] %t A055642 IntegerLength[Range[0,120]] (* _Harvey P. Dale_, Jul 02 2016 *) %o A055642 (PARI) a(n)=#Str(n) \\ _M. F. Hasler_, Nov 17 2008 %o A055642 (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 A055642 (Haskell) %o A055642 a055642 :: Integer -> Int %o A055642 a055642 = length . show -- _Reinhard Zumkeller_, Feb 19 2012, Apr 26 2011 %o A055642 (Magma) [ #Intseq(n): n in [0..105] ]; // _Bruno Berselli_, Jun 30 2011 %o A055642 (Common Lisp) (defun A055642 (n) (if (zerop n) 1 (floor (log n 10)))) ; _James Spahlinger_, Oct 13 2012 %o A055642 (Python) %o A055642 def a(n): return len(str(n)) %o A055642 print([a(n) for n in range(121)]) # _Michael S. Branicky_, May 10 2022 %o A055642 (Python) %o A055642 def A055642(n): # Faster than len(str(n)) from ~ 50 digits on %o A055642 L = math.log10(n or 1) %o A055642 if L.is_integer() and 10**int(L)>n: return int(L or 1) %o A055642 return int(L)+1 # _M. F. Hasler_, Apr 08 2024 %Y A055642 Cf. A043537, A178788, A046034, A019546, A054899, A122840, A055640, A055641, A102669-A102685, A117804, A160093, A160094, A196563, A196564, A000120, A000788, A023416, A059015 (for base 2). %Y A055642 Cf. A262190, A262198. %Y A055642 Cf. A007953: sum of digits. %K A055642 base,easy,nonn,nice %O A055642 0,11 %A A055642 _Henry Bottomley_, Jun 06 2000 # Content is available under The OEIS End-User License Agreement: http://oeis.org/LICENSE