login
Triangle read by rows: T(n,k) = sum of digits of n in base k representation, 1<=k<=n.
23

%I #19 Oct 25 2021 04:19:11

%S 1,2,1,3,2,1,4,1,2,1,5,2,3,2,1,6,2,2,3,2,1,7,3,3,4,3,2,1,8,1,4,2,4,3,

%T 2,1,9,2,1,3,5,4,3,2,1,10,2,2,4,2,5,4,3,2,1,11,3,3,5,3,6,5,4,3,2,1,12,

%U 2,2,3,4,2,6,5,4,3,2,1,13,3,3,4,5,3,7,6,5,4,3,2,1,14,3,4,5,6,4,2,7,6,5,4,3,2,1

%N Triangle read by rows: T(n,k) = sum of digits of n in base k representation, 1<=k<=n.

%C A131383(n) = sum of n-th row;

%C A000027(n) = T(n,1);

%C A000120(n) = T(n,2) for n>1;

%C A053735(n) = T(n,3) for n>2;

%C A053737(n) = T(n,4) for n>3;

%C A053824(n) = T(n,5) for n>4;

%C A053827(n) = T(n,6) for n>5;

%C A053828(n) = T(n,7) for n>6;

%C A053829(n) = T(n,8) for n>7;

%C A053830(n) = T(n,9) for n>8;

%C A007953(n) = T(n,10) for n>9;

%C A053831(n) = T(n,11) for n>10;

%C A053832(n) = T(n,12) for n>11;

%C A053833(n) = T(n,13) for n>12;

%C A053834(n) = T(n,14) for n>13;

%C A053835(n) = T(n,15) for n>14;

%C A053836(n) = T(n,16) for n>15;

%C A007395(n) = T(n,n-1) for n>1;

%C A000012(n) = T(n,n).

%H Alois P. Heinz, <a href="/A138530/b138530.txt">Rows n = 1..141, flattened</a>

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

%e Start of the triangle for n in base k representation:

%e ......................1

%e ....................11....10

%e ......... ........111....11...10

%e ................1111...100...11..10

%e ..............11111...101...12..11..10

%e ............111111...110...20..12..11..10

%e ..........1111111...111...21..13..12..11..10

%e ........11111111..1000...22..20..13..12..11..10

%e ......111111111..1001..100..21..14..13..12..11..10

%e ....1111111111..1010..101..22..20..14..13..12..11..10

%e ..11111111111..1011..102..23..21..15..14..13..12..11..10

%e 111111111111..1100..110..30..22..20..15..14..13..12..11..10,

%e and the triangle of sums of digits starts:

%e ......................1

%e .....................2...1

%e ......... ..........3...2...1

%e ...................4...1...2...1

%e ..................5...2...3...2...1

%e .................6...2...2...3...2...1

%e ................7...3...3...4...3...2...1

%e ...............8...1...4...2...4...3...2...1

%e ..............9...2...1...3...5...4...3...2...1

%e ............10...2...2...4...2...5...4...3...2...1

%e ...........11...3...3...5...3...6...5...4...3...2...1

%e ..........12...2...2...3...4...2...6...5...4...3...2...1.

%t T[n_, k_] := If[k == 1, n, Total[IntegerDigits[n, k]]];

%t Table[T[n, k], {n, 1, 14}, {k, 1, n}] // Flatten (* _Jean-François Alcover_, Oct 25 2021 *)

%o (Haskell)

%o a138530 n k = a138530_tabl !! (n-1) !! (k-1)

%o a138530_row n = a138530_tabl !! (n-1)

%o a138530_tabl = zipWith (map . flip q) [1..] a002260_tabl where

%o q 1 n = n

%o q b n = if n < b then n else q b n' + d where (n', d) = divMod n b

%o -- _Reinhard Zumkeller_, Apr 29 2015

%Y Cf. A007953. See A240236 for another version.

%Y Cf. A002260.

%K nonn,base,tabl

%O 1,2

%A _Reinhard Zumkeller_, Mar 26 2008