login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A355487
Bitwise XOR of the base-4 digits of n.
2
0, 1, 2, 3, 1, 0, 3, 2, 2, 3, 0, 1, 3, 2, 1, 0, 1, 0, 3, 2, 0, 1, 2, 3, 3, 2, 1, 0, 2, 3, 0, 1, 2, 3, 0, 1, 3, 2, 1, 0, 0, 1, 2, 3, 1, 0, 3, 2, 3, 2, 1, 0, 2, 3, 0, 1, 1, 0, 3, 2, 0, 1, 2, 3, 1, 0, 3, 2, 0, 1, 2, 3, 3, 2, 1, 0, 2, 3, 0, 1, 0, 1, 2, 3, 1, 0, 3
OFFSET
0,3
COMMENTS
Equivalently, the parity of the odd position 1-bits of n and the parity of the even position 1-bits of n, combined as a(n) = 2*A269723(n) + A341389(n).
In GF(2)[x] polynomials encoded as bits of an integer (least significant bit for the constant term), a(n) is remainder n mod x^2 + 1.
FORMULA
Fixed point of the morphism 0 -> 0,1; 1 -> 2,3; 2 -> 1,0; 3 -> 3,2 starting from 0.
EXAMPLE
n=35 has base-4 digits 203 so a(35) = 2 XOR 0 XOR 3 = 1.
MATHEMATICA
a[n_] := BitXor @@ IntegerDigits[n, 4]; Array[a, 100, 0] (* Amiram Eldar, Jul 05 2022 *)
PROG
(PARI) a(n) = if(n==0, 0, fold(bitxor, digits(n, 4)));
(Python)
from operator import xor
from functools import reduce
from sympy.ntheory import digits
def a(n): return reduce(xor, digits(n, 4)[1:])
print([a(n) for n in range(87)]) # Michael S. Branicky, Jul 05 2022
CROSSREFS
Cf. A030373 (base 4 digits), A003987 (XOR).
Cf. A353167 (indices of 0's).
Other digit operations: A053737 (sum), A309954 (product).
Sequence in context: A293113 A366528 A154720 * A071501 A004572 A352799
KEYWORD
nonn,base,easy
AUTHOR
Kevin Ryde, Jul 04 2022
STATUS
approved