A138530 Triangle read by rows: T(n,k) = sum of digits of n in base k representation, 1<=k<=n.
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, 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, 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
Offset: 1
Examples
Start of the triangle for n in base k representation: ......................1 ....................11....10 ......... ........111....11...10 ................1111...100...11..10 ..............11111...101...12..11..10 ............111111...110...20..12..11..10 ..........1111111...111...21..13..12..11..10 ........11111111..1000...22..20..13..12..11..10 ......111111111..1001..100..21..14..13..12..11..10 ....1111111111..1010..101..22..20..14..13..12..11..10 ..11111111111..1011..102..23..21..15..14..13..12..11..10 111111111111..1100..110..30..22..20..15..14..13..12..11..10, and the triangle of sums of digits starts: ......................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...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...2...2...3...4...2...6...5...4...3...2...1.
Links
- Alois P. Heinz, Rows n = 1..141, flattened
- Eric Weisstein's World of Mathematics, Digit Sum
Programs
-
Haskell
a138530 n k = a138530_tabl !! (n-1) !! (k-1) a138530_row n = a138530_tabl !! (n-1) a138530_tabl = zipWith (map . flip q) [1..] a002260_tabl where q 1 n = n q b n = if n < b then n else q b n' + d where (n', d) = divMod n b -- Reinhard Zumkeller, Apr 29 2015
-
Mathematica
T[n_, k_] := If[k == 1, n, Total[IntegerDigits[n, k]]]; Table[T[n, k], {n, 1, 14}, {k, 1, n}] // Flatten (* Jean-François Alcover, Oct 25 2021 *)
Comments