Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.
%I #47 Jul 18 2021 02:04:39
%S 0,1,2,3,4,7,6,5,8,11,14,13,12,15,10,9,16,19,22,21,28,31,26,25,24,27,
%T 30,29,20,23,18,17,32,35,38,37,44,47,42,41,56,59,62,61,52,55,50,49,48,
%U 51,54,53,60,63,58,57,40,43,46,45,36,39,34,33,64,67,70,69,76
%N Permutation of nonnegative integers: for each bit[i] in the binary representation, except the most and the least significant bits, set bit[i] = bit[i] XOR bit[i-1], where bit[i-1] is the less significant bit, XOR is the binary logical exclusive or operator.
%C This permutation transforms the enumeration system of positive irreducible fractions A020651/A020650 into the enumeration system A002487/A002487' (Calkin-Wilf), and enumeration system A245327/A245326 into A162911/A162912 (Drib). - _Yosu Yurramendi_, Jun 16 2015
%H Ivan Neretin, <a href="/A231550/b231550.txt">Table of n, a(n) for n = 0..8192</a>
%H <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the nonnegative integers</a>
%F a(A231551(n)) = A231551(a(n)) = n.
%F a(n) = A284460(A258996(n)) = A092569(A284460(n)), n > 0. - _Yosu Yurramendi_, Apr 10 2017
%t Join[{0, 1}, Table[d = IntegerDigits[n, 2]; FromDigits[Join[{d[[1]]}, BitXor[Most@Rest@d, Rest@Rest@d], {d[[-1]]}], 2], {n, 2, 68}]] (* _Ivan Neretin_, Dec 28 2016 *)
%o (Python)
%o for n in range(99):
%o bits = [0]*64
%o orig = [0]*64
%o l = int.bit_length(int(n))
%o t = n
%o for i in range(l):
%o bits[i] = orig[i] = t&1
%o t>>=1
%o for i in range(1, l-1): bits[i] ^= orig[i-1] # A231550
%o #for i in range(1, l-1): bits[i] ^= bits[i-1] # A231551
%o #for i in range(l-1): bits[i] ^= orig[i+1] # A003188
%o #for i in range(1,l): bits[l-1-i] ^= bits[l-i] # A006068
%o t = 0
%o for i in range(l): t += bits[i]<<i
%o print(str(t), end=',')
%o (R)
%o a <- 1
%o maxlevel <- 8 # by choice
%o #
%o for(m in 0:maxlevel) for(k in 0:(2^m-1)){
%o a[2^(m+1) +2*k] <- 2*a[2^m+k]
%o a[2^(m+2)-1-2*k] <- 2*a[2^m+k] + 1
%o }
%o (a <- c(0,a))
%o # _Yosu Yurramendi_, Apr 10 2017
%o (PARI) a(n) = bitxor(n, if(n>3, bitand(n<<1, bitneg(0,logint(n,2))))); \\ _Kevin Ryde_, Jul 17 2021
%Y Cf. A003188, A006068, A231551.
%K nonn,look,base,easy
%O 0,3
%A _Alex Ratushnyak_, Nov 10 2013