OFFSET
0,4
COMMENTS
Instead of interpreting the -1 as done in balanced ternary (as in A117966), read the newly formed string as a mathematical expression and evaluate it in ternary as if each "-" is a subtraction operator.
Those n which do not contain a 2 in ternary (A005836) remain unchanged and are record highs.
Those n which in ternary are a binary number prefixed by a 2 (A319953) give the record lows.
EXAMPLE
For n = 208893 = 101121112210_3, changing each 2 to a -1 gives 1011-1111-1-110; interpreting each "-" as a subtraction operator gives 1011_3 - 1111_3 - 1_3 - 110_3 = 31 - 40 - 1 - 12 = -22, so a(208893) = -22.
For n = 25 = 221_3, changing the 2's to (-1)'s gives -1-11; interpreting the leading "-" as a unary minus (so the expression starts with a negative 1) and the remaining "-" as a subtraction operator gives -1_3 - 11_3 = -1 - 4 = -5, so a(25) = -5.
PROG
(PARI) a(n) = my(v=digits(n, 3), lo=#v, ret=0); forstep(i=#v, 1, -1, if(v[i]==2, v[i]=1; ret -= fromdigits(v[i..lo], 3); lo=i-1)); ret + fromdigits(v[1..lo], 3); \\ Kevin Ryde, Jul 23 2021
CROSSREFS
KEYWORD
base,sign
AUTHOR
Johnathan Abdoo, Jul 21 2021
STATUS
approved