login
Balanced ternary expansion of e.
2

%I #11 Mar 04 2020 09:21:47

%S 1,0,-1,0,1,1,1,-1,-1,0,-1,0,-1,1,1,1,-1,0,1,1,1,-1,0,0,0,-1,1,1,-1,0,

%T 1,1,1,0,-1,0,0,0,-1,1,-1,-1,1,0,0,0,0,-1,1,1,0,-1,0,0,-1,-1,1,-1,1,

%U -1,-1,0,-1,-1,0,0,-1,1,1,1,0,0,1,-1,-1,1,0,0,0

%N Balanced ternary expansion of e.

%C For the first n digits of the sequence, take the smallest substring with n or more digits of the standard ternary expansion of e (A004594) such that it does not end with 1 and prepend a 0. For n = 15, this would be:

%C 0, 2, 2, 0, 1, 1, 0, 1, 1, 2, 1, 2, 2, 1, 1, 0.

%C Wherever there is a 2, change it to -1 and add 1 to the previous term:

%C 1, 0, -1, 0, 1, 1, 0, 1, 2, -1, 2, 0, -1, 1, 1, 0.

%C Repeat until no 2's remain:

%C 1, 0, -1, 0, 1, 1, 0, 2, -1, 0, -1, 0, -1, 1, 1, 0.

%C 1, 0, -1, 0, 1, 1, 1, -1, -1, 0, -1, 0, -1, 1, 1, 0.

%C Remove all but the first n digits:

%C 1, 0, -1, 0, 1, 1, 1, -1, -1, 0, -1, 0, -1, 1, 1.

%H Iain Fox, <a href="/A331990/b331990.txt">Table of n, a(n) for n = 2..20000</a>

%H Wikipedia, <a href="http://en.wikipedia.org/wiki/Balanced_ternary">Balanced ternary</a>

%e e = 2.7182818284... = 1 * 3^1 + 0 * 3^0 - 1 * 3^(-1) + 0 * 3^(-2) + 1 * 3^(-3) + ... = 10.T0111TT0T0..._bal3

%o (PARI) first(n) = {default(realprecision, 10000); for(x=-1, +oo, v=concat([0],digits(floor(exp(1)*3^(n+x)), 3)); if(v[#v]!=1, break())); while(vecmax(v)==2, for(x=1, #v, if(v[x]==2, v[x]=-1; v[x-1]++))); vecextract(v, 2^n-1)} \\ (adjust realprecision as needed)

%Y Pi in balanced ternary: A331313.

%Y Expansion of e in base b: A004593 (b = 2), A004594 (b = 3), A004595 (b = 4), A004596 (b = 5), A004597 (b = 6), A004598 (b = 7), A004599 (b = 8), A004600 (b = 9), A001113 (b = 10), A170873 (b = 16).

%K base,easy,sign

%O 2

%A _Iain Fox_, Feb 03 2020