cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A240236 Triangle read by rows: sum of digits of n in base k, for 2<=k<=n.

Original entry on oeis.org

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

Views

Author

Keywords

Examples

			Triangle starts:
  1
  2 1
  1 2 1
  2 3 2 1
  2 2 3 2 1
  3 3 4 3 2 1
		

Crossrefs

Row sums give A043306.
See A138530 for another version.

Programs

  • 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
  • Mathematica
    Table[Total[Flatten[IntegerDigits[n,k]]],{n,20},{k,2,n}]//Flatten (* Harvey P. Dale, Jan 13 2025 *)
  • PARI
    T(n,k) = local(r=0);if(k<2,-1,while(n>0,r+=n%k;n\=k);r)
    
  • PARI
    T(n, k) = sumdigits(n, k) \\ Zhuorui He, Aug 25 2025
    

Formula

T(n,k) = n - (k - 1) * Sum_{i=1..floor(log_k(n))} floor(n/k^i). - Ridouane Oudra, Sep 27 2024
T(n,k) = n - (k - 1) * A090623(n,k). - Zhuorui He, Aug 25 2025