|
|
A247891
|
|
a(n) is Gray-coded in base 4 into n.
|
|
0
|
|
|
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, 29, 30, 16, 17, 18, 19, 42, 43, 40, 41, 47, 44, 45, 46, 32, 33, 34, 35, 37, 38, 39, 36, 63, 60, 61, 62, 48, 49, 50, 51, 53, 54, 55, 52, 58, 59, 56, 57, 85, 86, 87, 84, 90
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
0,3
|
|
COMMENTS
|
Permutation of nonnegative numbers.
|
|
LINKS
|
|
|
FORMULA
|
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.
|
|
PROG
|
(Python)
def basexor(a, b, base):
result = 0
digit = 1
while a or b:
da = a % base
db = b % base
a //= base
b //= base
sum = (da+db) % base
result += sum * digit
digit *= base
return result
for n in range(129):
a = n
b = n//base
while b:
a = basexor(a, b, base)
b //= base
print str(a)+', ',
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn,base
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|