A165199 a(n) is obtained by flipping every second bit in the binary representation of n starting at the second-most significant bit and on downwards.
0, 1, 3, 2, 6, 7, 4, 5, 13, 12, 15, 14, 9, 8, 11, 10, 26, 27, 24, 25, 30, 31, 28, 29, 18, 19, 16, 17, 22, 23, 20, 21, 53, 52, 55, 54, 49, 48, 51, 50, 61, 60, 63, 62, 57, 56, 59, 58, 37, 36, 39, 38, 33, 32, 35, 34, 45, 44, 47, 46, 41, 40, 43, 42, 106, 107, 104, 105, 110, 111, 108
Offset: 0
Examples
a(12) = 9 because 12 = 1100_2 and 1100_2 XOR 0101_2 = 1001_2 = 9.
Links
Crossrefs
Programs
-
Maple
a:= n-> Bits[Xor](n, iquo(2^(1+ilog2(n)), 3)): seq(a(n), n=0..100); # Alois P. Heinz, Oct 07 2020
-
PARI
for(k=0,67,my(b(n)=vector(#digits(n,2),i,!(i%2)));print1(bitxor(k,fromdigits(b(k),2)),", ")) \\ Hugo Pfoertner, Oct 07 2020
-
PARI
a(n) = if(n, bitxor(n,2<
Kevin Ryde, Oct 07 2020 -
R
maxrow <- 8 # by choice a <- 1 for(m in 0: maxrow) for(k in 0:(2^m-1)){ a[2^(m+1) + k] = a[2^(m+1) - 1 - k] + 2^(m+1) a[2^(m+1) + 2^m + k] = a[2^(m+1) - 1 - k] + 2^m } (a <- c(0, a)) # Yosu Yurramendi, Apr 04 2017
Formula
Extensions
Extended by Ray Chandler, Sep 10 2009
a(0) = 0 prepended by Antti Karttunen, Jul 22 2014
New name from Kevin Ryde, Oct 07 2020
Comments