%I M0040 #65 Oct 06 2022 11:39:33
%S 1,2,1,0,1,1,1,2,2,0,2,1,2,2,1,0,0,1,0,1,1,0,2,1,1,0,1,1,1,1,1,2,1,2,
%T 0,1,2,1,1,2,2,2,0,0,2,0,1,2,0,2,2,1,0,2,1,1,2,1,2,2,2,0,2,2,1,2,2,2,
%U 1,0,0,0,1,0,0,1,1,0,0,2,1,0,1,0,1,0,1,1,1,0,1,2,1,0,2,0,1,0,2,1,1,0,2,2,1
%N Write n in base 3 and juxtapose.
%C An irregular table in which the n-th row lists the base-3 digits of n, see A007089. - _Jason Kimberley_, Dec 07 2012
%C The base-3 Champernowne constant (A077771): it is normal in base 3. - _Jason Kimberley_, Dec 07 2012
%D N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
%H Reinhard Zumkeller, <a href="/A003137/b003137.txt">Rows n = 1..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 1,
%e 2,
%e 1,0,
%e 1,1,
%e 1,2,
%e 2,0,
%e 2,1,
%e 2,2,
%e 1,0,0,
%e 1,0,1,.... _R. J. Mathar_, Aug 16 2021
%t Flatten@ IntegerDigits[ Range@ 40, 3] (* or *)
%t almostNatural[n_, b_] := Block[{m = 0, d = n, i = 1, l, p}, While[m <= d, l = m; m = (b - 1) i*b^(i - 1) + l; i++]; i--; p = Mod[d - l, i]; q = Floor[(d - l)/i] + b^(i - 1); If[p != 0, IntegerDigits[q, b][[p]], Mod[q - 1, b]]]; Array[ a[#, 3] &, 105] (* _Robert G. Wilson v_, Jul 01 2014 *)
%o (Magma) &cat[Reverse(IntegerToSequence(n,3)):n in[1..31]]; // _Jason Kimberley_, Dec 07 2012
%o (Haskell)
%o a003137 n k = a003137_tabf !! (n-1) !! k
%o a003137_row n = a003137_tabf !! (n-1)
%o a003137_tabf = map reverse $ tail a030341_tabf
%o a003137_list = concat a003137_tabf
%o -- _Reinhard Zumkeller_, Feb 21 2013
%o (Python)
%o from itertools import count, islice
%o from sympy.ntheory.factor_ import digits
%o def A003137_gen(): return (d for m in count(1) for d in digits(m,3)[1:])
%o A003137_list = list(islice(A003137_gen(),30)) # _Chai Wah Wu_, Jan 07 2022
%Y Tables in which the n-th row lists the base b digits of n: A030190 and A030302 (b=2), this sequence and A054635 (b=3), A030373 (b=4), A031219 (b=5), A030548 (b=6), A030998 (b=7), A031035 and A054634 (b=8), A031076 (b=9), A007376 and A033307 (b=10). - _Jason Kimberley_, Dec 06 2012
%Y Cf. A081604 (row lengths), A053735 (row sums), A030341 (rows reversed), A077771, A007089.
%K nonn,base,cons,easy,tabf
%O 1,2
%A _N. J. A. Sloane_
%E More terms from Larry Reeves (larryr(AT)acm.org), Sep 25 2000
|