login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A058183 Number of digits in concatenation of first n positive integers. 29

%I #63 May 04 2023 02:20:16

%S 1,2,3,4,5,6,7,8,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,

%T 45,47,49,51,53,55,57,59,61,63,65,67,69,71,73,75,77,79,81,83,85,87,89,

%U 91,93,95,97,99,101,103,105,107,109,111,113,115,117,119,121,123,125

%N Number of digits in concatenation of first n positive integers.

%C Or, total number of digits in numbers from 1 through n.

%H Alois P. Heinz, <a href="/A058183/b058183.txt">Table of n, a(n) for n = 1..10000</a>

%H GeeksforGeeks, <a href="https://www.geeksforgeeks.org/count-total-number-digits-1-n/">Count total number of digits from 1 to n</a>

%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/SmarandacheNumber.html">Smarandache Number</a>

%F a(n) = (n+1)*floor(log_10(10*n)) - (10^floor(log_10(10*n))-1)/(10-1).

%F a(n) = a(n-1) + floor(log_10(10*n)).

%F a(n) = A055642(A007908(n)).

%F a(n) = A055642(A053064(n)). - _Reinhard Zumkeller_, Oct 10 2008

%F a(n) ~ n log_10 n + O(n). In particular lim inf (n log_10 n - a(n))/n = (1+log(10/9)+log(log(10)))/log(10) and the corresponding lim sup is 10/9. - _Charles R Greathouse IV_, Sep 19 2012

%F G.f.: (1-x)^(-2)*Sum_{j>=0} x^(10^j). - _Robert Israel_, Nov 04 2015

%F a(n) = b(n)*(n + 1) - (10^b(n) - 19)/9 - 2, where b(n) = A055642(n). - _Lorenzo Sauras Altuzarra_, May 09 2020

%F a(n) = A055642(A000422(n)). - _Michel Marcus_, Sep 11 2021

%e a(12) = 15 since 123456789101112 has 15 digits.

%p a:= proc(n) a(n):= `if`(n=0, 0, a(n-1) +length(n)) end:

%p seq(a(n), n=1..100); # _Alois P. Heinz_, Nov 26 2013

%p a := proc(n) local d; d:=floor(log10(n))+1; (n+1)*d - (10^d-1)/9; end; # _N. J. A. Sloane_, Feb 20 2020

%t Length/@ Flatten/@ IntegerDigits/@ Flatten/@ Rest[FoldList[List, {}, Range[70]]] (* _Eric W. Weisstein_, Nov 04 2015 *)

%t Table[With[{d = IntegerLength[n]}, (n+1) d - (10^d -1)/9], {n, 70}] (* _Eric W. Weisstein_, Nov 06 2015 *)

%t IntegerLength/@ FoldList[#2 + #1 10^IntegerLength[#2] &, Range[70]] (* _Eric W. Weisstein_, Nov 06 2015 *)

%t Accumulate[ IntegerLength@ # & /@ Range @ 70] (* _Robert G. Wilson v_, Jul 31 2018 *)

%o (PARI) a(n)=my(t=log(10*n+.5)\log(10));n*t+t-10^t\9 \\ _Charles R Greathouse IV_, Sep 19 2012

%o (PARI) a(n) = sum(k=1, n, #digits(k)); \\ _Michel Marcus_, Jan 01 2017

%o (Python)

%o def A058183(n): return (n+1)*(s:=len(str(n))) - (10**s-1)//9 # _Chai Wah Wu_, May 02 2023

%Y Cf. A000422, A007908, A053064, A055642.

%K base,easy,nonn

%O 1,2

%A _Henry Bottomley_, Nov 17 2000

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 18 11:52 EDT 2024. Contains 371779 sequences. (Running on oeis4.)