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.

A233571 In balanced ternary notation, reverse digits of a(n) equals to -a(n).

This page as a plain text file.
%I A233571 #7 Dec 16 2013 12:28:24
%S A233571 0,2,8,20,26,32,56,80,104,146,164,182,224,242,260,302,320,338,416,488,
%T A233571 560,656,728,800,896,968,1040,1172,1226,1280,1406,1460,1514,1640,1694,
%U A233571 1748,1898,1952,2006,2132,2186,2240,2366,2420,2474,2624,2678,2732,2858
%N A233571 In balanced ternary notation, reverse digits of a(n) equals to -a(n).
%H A233571 Lei Zhou, <a href="/A233571/b233571.txt">Table of n, a(n) for n = 1..10000</a>
%e A233571 In balanced ternary notation, 8=(10T)_bt, where we use T to represent -1.  Reverse digits of (10T)_bt is (T01)_bt = -8. So 8 is in this sequence.
%e A233571 Similarly, 2240 = (1001T00T)_bt, whose reverse digits is (T00T1001)_bt = -2240.  So 2240 is in this sequence.
%t A233571 BTDigits[m_Integer, g_] :=
%t A233571 Module[{n = m, d, sign, t = g},
%t A233571   If[n != 0, If[n > 0, sign = 1, sign = -1; n = -n];
%t A233571    d = Ceiling[Log[3, n]]; If[3^d - n <= ((3^d - 1)/2), d++];
%t A233571    While[Length[t] < d, PrependTo[t, 0]]; t[[Length[t] + 1 - d]] = sign;
%t A233571    t = BTDigits[sign*(n - 3^(d - 1)), t]]; t];
%t A233571 ct = 1; n = 0; m = 0; dg = 0; switch = 1; res = {0}; While[ct < 50, n++;
%t A233571   bits = BTDigits[n, {0}]; If[lb = Length[bits]; lb > dg,
%t A233571   If[switch == 0, n = m; switch = 1; OK = 0, dg = lb; m = n - 1;
%t A233571    switch = 0; OK = 1], OK = 1];  If[OK == 1, rbt = -Reverse[bits];
%t A233571   If[switch == 1, nb = Join[bits, {0}], nb = bits];
%t A233571   nb = Join[nb, rbt]; nb = Reverse[nb]; data = 0;
%t A233571   Do[data = data + 3^(i - 1)*nb[[i]], {i, 1, Length[nb]}]; ct++;
%t A233571   AppendTo[res, data]]]; res
%Y A233571 Cf. A002113, A061917, A006995, A057890, A134027, A233010
%K A233571 nonn,easy,base
%O A233571 1,2
%A A233571 _Lei Zhou_, Dec 13 2013