(Translated by https://www.hiragana.jp/)
A055642 - OEIS
login
A055642
Number of digits in the decimal expansion of n.
475
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, 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, 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
OFFSET
0,11
COMMENTS
From Hieronymus Fischer, Jun 08 2012: (Start)
For n > 0 the first differences of A117804.
The total number of digits necessary to write down all the numbers 0, 1, 2, ..., n is A117804(n+1). (End)
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
LINKS
Charles R Greathouse IV, Table of n, a(n) for n = 0..10000
FORMULA
a(A046760(n)) < A050252(A046760(n)); a(A046759(n)) > A050252(A046759(n)). - Reinhard Zumkeller, Jun 21 2011
a(n) = A196563(n) + A196564(n).
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
a(A046758(n)) = A050252(A046758(n)). - Reinhard Zumkeller, Jun 21 2011
a(n) = A117804(n+1) - A117804(n), n > 0. - Hieronymus Fischer, Jun 08 2012
G.f.: g(x) = 1 + (1/(1-x))*Sum_{j>=0} x^(10^j). - Hieronymus Fischer, Jun 08 2012
a(n) = A262190(n) for n < 100; a(A262198(n)) != A262190(A262198(n)). - Reinhard Zumkeller, Sep 14 2015
EXAMPLE
Examples:
999: 1 + floor(log_10(999)) = 1 + floor(2.x) = 1 + 2 = 3 or
ceiling(log_10(999+1)) = ceiling(log_10(1000)) = ceiling(3) = 3;
1000: 1 + floor(log_10(1000)) = 1 + floor(3) = 1 + 3 = 4 or
ceiling(log_10(1000+1)) = ceiling(log_10(1001)) = ceiling(3.x) = 4;
1001: 1 + floor(log_10(1001)) = 1 + floor(3.x) = 1 + 3 = 4 or
ceiling(log_10(1001+1)) = ceiling(log_10(1002)) = ceiling(3.x) = 4;
MAPLE
A055642 := proc(n)
max(1, ilog10(n)+1) ;
end proc: # R. J. Mathar, Nov 30 2011
MATHEMATICA
Join[{1}, Array[ Floor[ Log[10, 10# ]] &, 104]] (* Robert G. Wilson v, Jan 04 2006 *)
Join[{1}, Table[IntegerLength[n], {n, 104}]]
IntegerLength[Range[0, 120]] (* Harvey P. Dale, Jul 02 2016 *)
PROG
(PARI) a(n)=#Str(n) \\ M. F. Hasler, Nov 17 2008
(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
(Haskell)
a055642 :: Integer -> Int
a055642 = length . show -- Reinhard Zumkeller, Feb 19 2012, Apr 26 2011
(Magma) [ #Intseq(n): n in [0..105] ]; // Bruno Berselli, Jun 30 2011
(Common Lisp) (defun A055642 (n) (if (zerop n) 1 (floor (log n 10)))) ; James Spahlinger, Oct 13 2012
(Python)
def a(n): return len(str(n))
print([a(n) for n in range(121)]) # Michael S. Branicky, May 10 2022
(Python)
def A055642(n): # Faster than len(str(n)) from ~ 50 digits on
L = math.log10(n or 1)
if L.is_integer() and 10**int(L)>n: return int(L or 1)
return int(L)+1 # M. F. Hasler, Apr 08 2024
KEYWORD
base,easy,nonn,nice
AUTHOR
Henry Bottomley, Jun 06 2000
STATUS
approved