OFFSET
0,6
LINKS
Rémy Sigrist, Table of n, a(n) for n = 0..9841
FORMULA
a(n) = 0 iff n belongs to A005836.
EXAMPLE
For n = 42:
- the numbers k around 42, alongside their distance to 42, ternary expansion and whether they require carries when added to 42, are:
k d ter(k) carries?
-- - ------ --------
38 4 1102 no
39 3 1110 yes
40 2 1111 yes
41 1 1112 yes
42 0 1120 yes
43 1 1121 yes
44 2 1122 yes
45 3 1200 yes
46 4 1201 yes
- so a(42) = 4.
PROG
(PARI) ok(u, v) = sumdigits(u+v, 3)==sumdigits(u, 3)+sumdigits(v, 3)
a(n) = { for (d=0, oo, if (ok(n, n-d) || ok(n, n+d), return (d))) }
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, Apr 27 2022
STATUS
approved