cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A353157 a(n) is the distance from n to the nearest integer whose binary expansion has no common 1-bits with that of n.

This page as a plain text file.
%I A353157 #12 May 01 2022 11:41:15
%S A353157 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,
%T A353157 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,
%U A353157 6,5,4,3,2,1,1,3,5,7,9,11,13,15,17,19,21,23,25
%N A353157 a(n) is the distance from n to the nearest integer whose binary expansion has no common 1-bits with that of n.
%C A353157 Equivalently the distance to the nearest integer that can be added without carries in base 2.
%H A353157 Rémy Sigrist, <a href="/A353157/b353157.txt">Table of n, a(n) for n = 0..8192</a>
%H A353157 <a href="/index/Bi#binary">Index entries for sequences related to binary expansion of n</a>
%F A353157 a(n) = min(A006257(n), A080079(n)) for any n > 0.
%F A353157 a(n) = 1 iff n belongs to A097110.
%F A353157 a(n) = n/2 iff n belongs to A020988.
%F A353157 a(n) = n/4 iff n belongs to A108019.
%F A353157 2*a(n) - a(2*n) = 0 or 1.
%e A353157 For n = 42 ("101010" in binary):
%e A353157 - 21 ("10101") is the greatest number <= 42 that has no common 1-bits with 42,
%e A353157 - 128 ("1000000") is the least number >= 42 that has no common 1-bits with 42,
%e A353157 - so a(42) = min(42-21, 128-42) = min(21, 86) = 21.
%o A353157 (PARI) a(n) = { my (high=2^#binary(n), low=high-1-n); min(n-low, high-n) }
%Y A353157 Cf. A006257, A020988, A097110, A080079, A108019, A353158.
%K A353157 nonn,base
%O A353157 0,6
%A A353157 _Rémy Sigrist_, Apr 27 2022