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.

A108731 Triangle read by rows: row n gives digits of n in factorial base.

Original entry on oeis.org

0, 1, 1, 0, 1, 1, 2, 0, 2, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 2, 0, 1, 2, 1, 2, 0, 0, 2, 0, 1, 2, 1, 0, 2, 1, 1, 2, 2, 0, 2, 2, 1, 3, 0, 0, 3, 0, 1, 3, 1, 0, 3, 1, 1, 3, 2, 0, 3, 2, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 2, 0, 1, 0, 2, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1
Offset: 0

Views

Author

Keywords

Comments

Row lengths are A084558. This sequence contains every finite sequence of nonnegative integers.
T(n,k)=A235168(n,k) for k=0..23; a(n) = A235168(n) for n=0..63, when both tables are seen as flattened lists. - Reinhard Zumkeller, Jan 05 2014

Examples

			Triangle begins:
  0
  1
  1, 0
  1, 1
  2, 0
  2, 1
  1, 0, 0
For example, 11 in factorial base is 121 (1*6 + 2*2 + 1*1), so row 11 is 1,2,1.
		

Crossrefs

Programs

  • Haskell
    a108731 n k = a108731_row n !! k
    a108731_row 0 = [0]
    a108731_row n = t n $ reverse $ takeWhile (<= n) $ tail a000142_list
       where t 0 []     = []
             t x (b:bs) = x' : t m bs where (x',m) = divMod x b
    a108731_tabf = map a108731_row [0..]
    -- Reinhard Zumkeller, Jun 04 2012
    
  • Maple
    b:= proc(n, i) local r; `if`(n b(n, 2)[]:
    seq(T(n), n=0..50);  # Alois P. Heinz, Mar 19 2014
  • Mathematica
    b[n_, i_] := b[n, i] = Module[{q, r}, If[n < i, {n}, {q, r} = QuotientRemainder[n, i]; Append[b[q, i + 1], r]]];
    T[n_] := b[n, 2];
    Table[T[n], {n, 0, 40}] // Flatten (* Jean-François Alcover, Feb 03 2018, after Alois P. Heinz *)
  • PARI
    A108731_row(n)={n=[n];while(n[1],n=concat(divrem(n[1],1+#n),n[^1]);n[1]||break);n[^1]~} \\ M. F. Hasler, Jun 20 2017
    
  • Python
    def row(n, i=2): return [n] if n < i else [*row(n//i, i=i+1), n%i]
    print([d for n in range(35) for d in row(n)]) # Michael S. Branicky, Oct 02 2024

Extensions

Added a(0)=0 and offset changed accordingly by Reinhard Zumkeller, Jun 04 2012