OFFSET
0,3
LINKS
Wikipedia, Bitwise operation
EXAMPLE
a(12) = 1 XOR 2 = 01_2 XOR 10_2 = 11_2 = 3.
MAPLE
b:= l-> `if`(l=[], 0, Bits[Xor](l[1], b(subsop(1=[][], l)))):
a:= n-> b(convert(n, base, 10)):
seq(a(n), n=0..82); # Alois P. Heinz, Jul 21 2021
MATHEMATICA
Table[BitXor @@ IntegerDigits[n], {n, 0, 100}] (* Amiram Eldar, Jul 21 2021 *)
PROG
(Sage)
def XOR(a, b):
return a ^^ b
[reduce(XOR, map(lambda x: int(x), str(n))) for n in (0..1000)]
(PARI) a(n) = my(d=digits(n), k=0); for (i=1, #d, k= bitxor(k, d[i])); k; \\ Michel Marcus, Jul 21 2021
CROSSREFS
KEYWORD
base,nonn
AUTHOR
Jeremias M. Gomes, Jul 21 2021
STATUS
approved