OFFSET
0,2
COMMENTS
Two integers can be added without carries in balanced ternary if they have no equal nonzero digit at the same position.
LINKS
Rémy Sigrist, Table of n, a(n) for n = 0..10000
Wikipedia, Balanced ternary
FORMULA
a(n) = A353624(n) / n for any n > 0.
a(3*n) = a(n).
EXAMPLE
For n = 5:
- we consider the following cases:
k bter(k*5) carries?
- --------- --------
1 1TT yes
2 101 yes
3 1TT0 yes
4 1T1T yes
5 10T1 yes
6 1010 no
- so a(5) = 6.
PROG
(PARI) ok(u, v) = { while (u && v, my (uu=[0, +1, -1][1+u%3], vv=[0, +1, -1][1+v%3]); if (abs(uu+vv)>1, return (0)); u=(u-uu)/3; v=(v-vv)/3); return (1) }
a(n) = for (k=1, oo, if (ok(n, n*k), return (k)))
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, Apr 30 2022
STATUS
approved