A030341 Triangle T(n,k): write n in base 3, reverse order of digits.
0, 1, 2, 0, 1, 1, 1, 2, 1, 0, 2, 1, 2, 2, 2, 0, 0, 1, 1, 0, 1, 2, 0, 1, 0, 1, 1, 1, 1, 1, 2, 1, 1, 0, 2, 1, 1, 2, 1, 2, 2, 1, 0, 0, 2, 1, 0, 2, 2, 0, 2, 0, 1, 2, 1, 1, 2, 2, 1, 2, 0, 2, 2, 1, 2, 2, 2, 2, 2, 0, 0, 0, 1, 1, 0, 0, 1, 2, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 2, 1, 0, 1
Offset: 0
Examples
Triangle begins : 0 1 2 0, 1 1, 1 2, 1 0, 2 1, 2 2, 2 0, 0, 1 1, 0, 1 2, 0, 1 0, 1, 1 1, 1, 1 2, 1, 1 ...
Links
- Reinhard Zumkeller, Rows n = 0..1000 of triangle, flattened
- Eric Weisstein's World of Mathematics, Ternary.
- Wikipedia, Ternary numeral system
Crossrefs
Programs
-
Haskell
a030341 n k = a030341_tabf !! n !! k a030341_row n = a030341_tabf !! n a030341_tabf = iterate succ [0] where succ [] = [1] succ (2:ts) = 0 : succ ts succ (t:ts) = (t + 1) : ts -- Reinhard Zumkeller, Feb 21 2013
-
Maple
A030341_row := n -> op(convert(n, base, 3)): seq(A030341_row(n), n=0..32); # Peter Luschny, Nov 28 2017
-
Mathematica
Flatten[Table[Reverse[IntegerDigits[n,3]],{n,0,40}]] (* Harvey P. Dale, Oct 20 2014 *)
-
PARI
A030341(n, k=-1)=/*k<0&&error("Flattened sequence not yet implemented.")*/n\3^k%3 \\ Assuming that columns are numbered starting with k=0 as in A030308, A030567 and others. - M. F. Hasler, Jul 21 2013
Extensions
Initial 0 and better name by Philippe Deléham, Oct 20 2011