%I #9 Nov 07 2014 23:04:35
%S 0,1,2,3,5,6,7,4,10,11,8,9,15,12,13,14,21,22,23,20,26,27,24,25,31,28,
%T 29,30,16,17,18,19,42,43,40,41,47,44,45,46,32,33,34,35,37,38,39,36,63,
%U 60,61,62,48,49,50,51,53,54,55,52,58,59,56,57,85,86,87,84,90
%N a(n) is Gray-coded in base 4 into n.
%C Permutation of nonnegative numbers.
%H <a href="/index/Per#IntegerPermutation">Index entries for sequences that are permutations of the natural numbers</a>
%F a(n) = n XOR4 [n/4] XOR4 [n/16] XOR4 [n/64] ... XOR4 [n/4^m] where m = [log(n)/log(4)], [x] is integer floor of x, and XOR4 is a base 4 analog of binary exclusive-OR operator.
%o (Python)
%o def basexor(a, b, base):
%o result = 0
%o digit = 1
%o while a or b:
%o da = a % base
%o db = b % base
%o a //= base
%o b //= base
%o sum = (da+db) % base
%o result += sum * digit
%o digit *= base
%o return result
%o base = 4 # 2 => A006068, 3 => A105529, 10 => A226134
%o for n in range(129):
%o a = n
%o b = n//base
%o while b:
%o a = basexor(a,b, base)
%o b //= base
%o print str(a)+',',
%Y Cf. A006068 (base 2), A105529 (base 3), A226134 (base 10).
%K nonn,base
%O 0,3
%A _Alex Ratushnyak_, Sep 26 2014