A182402 Total number of digits in n-th row of a triangle formed by the positive integers.
1, 2, 3, 5, 10, 12, 14, 16, 18, 20, 22, 24, 26, 34, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90, 93, 96, 99, 102, 105, 108, 111, 114, 117, 120, 123, 126, 129, 132, 171, 184, 188, 192, 196, 200, 204, 208, 212, 216, 220, 224, 228, 232
Offset: 1
Examples
1; .................... (row 1 contains 1 digit) 2, 3; ............... (row 2 contains 2 digits) 4, 5, 6; ........... (row 3 contains 3 digits) 7, 8, 9, 10; ....... (row 4 contains 5 digits) 11, 12, 13, 14, 15; ... (row 5 contains 10 digits)
Links
- Reinhard Zumkeller, Table of n, a(n) for n = 1..10000
Programs
-
Haskell
a182402 n = a182402_list !! (n-1) a182402_list = map (sum . map a055642) $ t 1 [1..] where t i xs = ys : t (i + 1) zs where (ys, zs) = splitAt i xs -- Reinhard Zumkeller, May 26 2013
-
Mathematica
f[n_] := Length@ Flatten[ IntegerDigits[ Range[n (n - 1)/2 + 1, n (n + 1)/2]]]; Array[f, 58] (* Robert G. Wilson v, Sep 04 2013 *)
-
PARI
a(n) = {my(x=n*(n-1)/2+1, y=n*(n+1)/2, nx=#Str(x), ny=#Str(y), s=0); for (i=nx, ny, if (i==nx, if (i==ny, s+=(y+1-x)*i, s+=(10^i-x)*i), if (i==ny, s+=(y+1-10^(i-1))*i, s+=i*(10^(i+1)-10^i+1)););); s;} \\ Michel Marcus, Jan 26 2022
-
Python
def a(n): return len("".join(str(i) for i in range(n*(n+1)//2+1, (n+1)*(n+2)//2+1))) print([a(n) for n in range(58)]) # Michael S. Branicky, Jan 26 2022
Formula
Extensions
Better definition from Omar E. Pol, Jun 25 2012
Comments