OFFSET
0,1
COMMENTS
a(n) = n<+>2 (see comment in A206853).
LINKS
Alois P. Heinz, Table of n, a(n) for n = 0..1000
FORMULA
If n is odd, then a(n) = n+2^(A007814(n+1)-1); if n == 2 (mod 4), then a(n) = n+2^(A007814(n+2)-1); if n == 0 (mod 4), then a(n) = n+3.
Using this formula, we can prove the conjecture formulated in comment in A209554 in the case k=2. Moreover, let us show that if N does not have the form 8*t or 8*t+1, then it can be represented in the form n<+>2. Indeed, in the cases N = 8*t+2, 8*t+4, 8*t+6, 8*t+3, 8*t+5 and 8*t+7 it is sufficient to choose n=N-4, n=N-2, n=N-1, n=N-3, n=N-2 and n = N-3 respectively; in the cases 8*t, 8*t+1, for every choice of n <= N, we do not obtain the equality n<+>2 = N.
MAPLE
HD:= (i, j)-> add(h, h=Bits[Split](Bits[Xor](i, j))):
a:= proc(n) local c;
for c from n do if HD(n, c)=2 then return c fi od
end:
seq(a(n), n=0..100); # Alois P. Heinz, Apr 17 2012
MATHEMATICA
t={}; Do[i=n+1; While[Count[IntegerDigits[BitXor[n, i], 2], 1]!=2, i++]; AppendTo[t, i], {n, 0, 66}]; t (* Jayanta Basu, May 26 2013 *)
PROG
(Sage)
def A182187(n):
S = n.bits(); T = S; c = n; L = len(S)
while true:
H = sum(a != b for a, b in zip(S, T))
if H == 2: return c
c += 1; T = c.bits()
if len(T) > L: L += 1; S.append(0)
[A182187(n) for n in (0..66)] # Peter Luschny, May 26 2013
(Python)
def a(n):
m = n + 1
while bin(n^m).count('1') != 2: m += 1
return m
print([a(n) for n in range(67)]) # Michael S. Branicky, Mar 02 2021
(PARI) a(n) = bitxor(n, 3<<valuation(n>>1+1, 2)); \\ Kevin Ryde, Jul 09 2021
CROSSREFS
KEYWORD
nonn,base,easy
AUTHOR
Vladimir Shevelev, Apr 17 2012
EXTENSIONS
More terms from Alois P. Heinz, Apr 17 2012
STATUS
approved