login
Triangle T(n,k): write n in base 3, reverse order of digits.
44

%I #33 Jan 24 2021 10:18:58

%S 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,

%T 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,

%U 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

%N Triangle T(n,k): write n in base 3, reverse order of digits.

%H Reinhard Zumkeller, <a href="/A030341/b030341.txt">Rows n = 0..1000 of triangle, flattened</a>

%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/Ternary.html">Ternary.</a>

%H Wikipedia, <a href="http://en.wikipedia.org/wiki/Ternary_numeral_system">Ternary numeral system</a>

%e Triangle begins :

%e 0

%e 1

%e 2

%e 0, 1

%e 1, 1

%e 2, 1

%e 0, 2

%e 1, 2

%e 2, 2

%e 0, 0, 1

%e 1, 0, 1

%e 2, 0, 1

%e 0, 1, 1

%e 1, 1, 1

%e 2, 1, 1 ...

%p A030341_row := n -> op(convert(n, base, 3)):

%p seq(A030341_row(n), n=0..32); # _Peter Luschny_, Nov 28 2017

%t Flatten[Table[Reverse[IntegerDigits[n,3]],{n,0,40}]] (* _Harvey P. Dale_, Oct 20 2014 *)

%o (Haskell)

%o a030341 n k = a030341_tabf !! n !! k

%o a030341_row n = a030341_tabf !! n

%o a030341_tabf = iterate succ [0] where

%o succ [] = [1]

%o succ (2:ts) = 0 : succ ts

%o succ (t:ts) = (t + 1) : ts

%o -- _Reinhard Zumkeller_, Feb 21 2013

%o (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

%Y Cf. A081604 (row lengths), A053735 (row sums), A007089, A003137.

%Y Cf. A030308, A030386, A031235, A030567, A031007, A031045, A031087, A031298 for the base-2 to base-10 analogs.

%K nonn,base,tabf,less

%O 0,3

%A _Clark Kimberling_

%E Initial 0 and better name by _Philippe Deléham_, Oct 20 2011