OFFSET
2
COMMENTS
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:
0, 2, 2, 0, 1, 1, 0, 1, 1, 2, 1, 2, 2, 1, 1, 0.
Wherever there is a 2, change it to -1 and add 1 to the previous term:
1, 0, -1, 0, 1, 1, 0, 1, 2, -1, 2, 0, -1, 1, 1, 0.
Repeat until no 2's remain:
1, 0, -1, 0, 1, 1, 0, 2, -1, 0, -1, 0, -1, 1, 1, 0.
1, 0, -1, 0, 1, 1, 1, -1, -1, 0, -1, 0, -1, 1, 1, 0.
Remove all but the first n digits:
1, 0, -1, 0, 1, 1, 1, -1, -1, 0, -1, 0, -1, 1, 1.
LINKS
Iain Fox, Table of n, a(n) for n = 2..20000
Wikipedia, Balanced ternary
EXAMPLE
e = 2.7182818284... = 1 * 3^1 + 0 * 3^0 - 1 * 3^(-1) + 0 * 3^(-2) + 1 * 3^(-3) + ... = 10.T0111TT0T0..._bal3
PROG
(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)
CROSSREFS
KEYWORD
base,easy,sign
AUTHOR
Iain Fox, Feb 03 2020
STATUS
approved