A108731 Triangle read by rows: row n gives digits of n in factorial base.
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
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.
Links
- Reinhard Zumkeller, Rows n = 0..2000 of triangle, flattened
- C. A. Laisant, Sur la numération factorielle, application aux permutations, Bulletin de la Société Mathématique de France, 16 (1888), p. 176-183.
- Wikipedia, Factorial number system
- Index entries for sequences related to factorial base representation
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
Comments