login
A240236
Triangle read by rows: sum of digits of n in base k, for 2<=k<=n.
7
1, 2, 1, 1, 2, 1, 2, 3, 2, 1, 2, 2, 3, 2, 1, 3, 3, 4, 3, 2, 1, 1, 4, 2, 4, 3, 2, 1, 2, 1, 3, 5, 4, 3, 2, 1, 2, 2, 4, 2, 5, 4, 3, 2, 1, 3, 3, 5, 3, 6, 5, 4, 3, 2, 1, 2, 2, 3, 4, 2, 6, 5, 4, 3, 2, 1, 3, 3, 4, 5, 3, 7, 6, 5, 4, 3, 2, 1, 3, 4, 5, 6, 4, 2, 7, 6, 5, 4, 3, 2, 1
OFFSET
2,2
LINKS
FORMULA
T(n,k) = n - (k - 1) * Sum_{i=1..floor(log_k(n))} floor(n/k^i). - Ridouane Oudra, Sep 27 2024
EXAMPLE
Triangle starts:
1
2 1
1 2 1
2 3 2 1
2 2 3 2 1
3 3 4 3 2 1
PROG
(PARI) T(n, k) = local(r=0); if(k<2, -1, while(n>0, r+=n%k; n\=k); r)
(Haskell)
a240236 n k = a240236_tabl !! (n-1) !! (k-1)
a240236_row n = a240236_tabl !! (n-1)
a240236_tabl = zipWith (map . flip q)
[2..] (map tail $ tail a002260_tabl) where
q b n = if n < b then n else q b n' + d where (n', d) = divMod n b
-- Reinhard Zumkeller, Apr 29 2015
CROSSREFS
Row sums give A043306.
See A138530 for another version.
Cf. A002260.
Sequence in context: A025837 A111317 A105202 * A356606 A099386 A161067
KEYWORD
nonn,tabl,base
AUTHOR
STATUS
approved