login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A353158 a(n) is the distance from n to the nearest integer that can be added to n without carries in base 3. 3
0, 0, 1, 0, 0, 2, 3, 2, 1, 0, 0, 1, 0, 0, 2, 4, 6, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 1, 0, 0, 2, 3, 2, 1, 0, 0, 1, 0, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4 (list; graph; refs; listen; history; text; internal format)
OFFSET
0,6
LINKS
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
Cf. A005836 (positions of zeros), A167877, A353157 (binary variant).
Sequence in context: A017878 A301572 A017868 * A334476 A319573 A178904
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, Apr 27 2022
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 16 16:01 EDT 2024. Contains 371749 sequences. (Running on oeis4.)