%I #55 Mar 12 2021 07:52:05
%S 0,1,2,3,4,1,6,7,8,5,2,7,12,1,14,15,16,13,10,7,4,5,14,11,24,13,2,15,
%T 28,1,30,31,32,29,26,7,20,13,14,3,8,1,10,11,28,5,22,19,48,21,26,15,4,
%U 13,30,19,56,29,2,31,60,1,62,63,64,61,58,7,52,29,14,19,40,25,26,3,28,13,6,11,16,9,2,11,20,1,22
%N a(0) = 0, a(1) = 1, a(2*n) = 2*a(n), a(2*n+1) = a(n) XOR a(n+1).
%C a(n) is the n-th Stern polynomial (cf. A260443, A125184) evaluated at X = 2 over the field GF(2).
%C For n >= 1, a(n) gives the index of the row where n occurs in array A277710.
%H Antti Karttunen, <a href="/A264977/b264977.txt">Table of n, a(n) for n = 0..16384</a>
%F a(0) = 0, a(1) = 1, a(2*n) = 2*a(n), a(2*n+1) = a(n) XOR a(n+1).
%F a(n) = A248663(A260443(n)).
%F a(n) = A048675(A277330(n)). - _Antti Karttunen_, Oct 27 2016
%F Other identities. For all n >= 0:
%F a(n) = n - A265397(n).
%F From _Antti Karttunen_, Oct 28 2016: (Start)
%F A000035(a(n)) = A000035(n). [Preserves the parity of n.]
%F A010873(a(n)) = A010873(n). [a(n) mod 4 = n mod 4.]
%F A001511(a(n)) = A001511(n) = A055396(A277330(n)). [In general, the 2-adic valuation of n is preserved.]
%F A010060(a(n)) = A011655(n).
%F a(n) <= n.
%F For n >= 2, a((2^n)+1) = (2^n) - 3.
%F The following two identities are so far unproved:
%F For n >= 2, a(3*A000225(n)) = a(A068156(n)) = 5.
%F For n >= 2, a(A068156(n)-2) = A062709(n) = 2^n + 3.
%F (End)
%e In this example, binary numbers are given zero-padded to four bits.
%e a(2) = 2a(1) = 2 * 1 = 2.
%e a(3) = a(1) XOR a(2) = 1 XOR 2 = 0001 XOR 0010 = 0011 = 3.
%e a(4) = 2a(2) = 2 * 2 = 4.
%e a(5) = a(2) XOR a(3) = 2 XOR 3 = 0010 XOR 0011 = 0001 = 1.
%e a(6) = 2a(3) = 2 * 3 = 6.
%e a(7) = a(3) XOR a(4) = 3 XOR 4 = 0011 XOR 0100 = 0111 = 7.
%t recurXOR[0] = 0; recurXOR[1] = 1; recurXOR[n_] := recurXOR[n] = If[EvenQ[n], 2recurXOR[n/2], BitXor[recurXOR[(n - 1)/2 + 1], recurXOR[(n - 1)/2]]]; Table[recurXOR[n], {n, 0, 100}] (* _Jean-François Alcover_, Oct 23 2016 *)
%o (Scheme, with memoization-macro definec)
%o (definec (A264977 n) (cond ((<= n 1) n) ((even? n) (* 2 (A264977 (/ n 2)))) (else (A003987bi (A264977 (/ (- n 1) 2)) (A264977 (/ (+ n 1) 2))))))
%o ;; Where A003987bi computes bitwise-XOR as in A003987.
%o (Python)
%o class Memoize:
%o def __init__(self, func):
%o self.func=func
%o self.cache={}
%o def __call__(self, arg):
%o if arg not in self.cache:
%o self.cache[arg] = self.func(arg)
%o return self.cache[arg]
%o @Memoize
%o def a(n): return n if n<2 else 2*a(n//2) if n%2==0 else a((n - 1)//2)^a((n + 1)//2)
%o print([a(n) for n in range(51)]) # _Indranil Ghosh_, Jul 27 2017
%Y Cf. A000225, A001511, A002487, A003987, A010060, A011655, A048675, A055396, A125184, A248663, A260443, A265397, A277330.
%Y Cf. A023758 (the fixed points).
%Y Cf. also A068156, A168081, A265407.
%Y Cf. A277700 (binary weight of terms).
%Y Cf. A277701, A277712, A277713 (positions of 1's, 2's and 3's in this sequence).
%Y Cf. A277711 (position of the first occurrence of each n in this sequence).
%Y Cf. also arrays A277710, A099884.
%K nonn,look
%O 0,3
%A _Antti Karttunen_, Dec 10 2015