The OEIS mourns the passing of Jim Simons and is grateful to the Simons Foundation for its support of research in many branches of science, including the OEIS.
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!)
A353157 a(n) is the distance from n to the nearest integer whose binary expansion has no common 1-bits with that of n. 2
0, 1, 1, 1, 1, 3, 2, 1, 1, 3, 5, 5, 4, 3, 2, 1, 1, 3, 5, 7, 9, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25 (list; graph; refs; listen; history; text; internal format)
OFFSET
0,6
COMMENTS
Equivalently the distance to the nearest integer that can be added without carries in base 2.
LINKS
FORMULA
a(n) = min(A006257(n), A080079(n)) for any n > 0.
a(n) = 1 iff n belongs to A097110.
a(n) = n/2 iff n belongs to A020988.
a(n) = n/4 iff n belongs to A108019.
2*a(n) - a(2*n) = 0 or 1.
EXAMPLE
For n = 42 ("101010" in binary):
- 21 ("10101") is the greatest number <= 42 that has no common 1-bits with 42,
- 128 ("1000000") is the least number >= 42 that has no common 1-bits with 42,
- so a(42) = min(42-21, 128-42) = min(21, 86) = 21.
PROG
(PARI) a(n) = { my (high=2^#binary(n), low=high-1-n); min(n-low, high-n) }
CROSSREFS
Sequence in context: A152176 A152175 A321620 * A134520 A188316 A197027
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 May 21 05:34 EDT 2024. Contains 372728 sequences. (Running on oeis4.)