|
|
A264977
|
|
a(0) = 0, a(1) = 1, a(2*n) = 2*a(n), a(2*n+1) = a(n) XOR a(n+1).
|
|
23
|
|
|
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, 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, 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
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
0,3
|
|
COMMENTS
|
a(n) is the n-th Stern polynomial (cf. A260443, A125184) evaluated at X = 2 over the field GF(2).
For n >= 1, a(n) gives the index of the row where n occurs in array A277710.
|
|
LINKS
|
|
|
FORMULA
|
a(0) = 0, a(1) = 1, a(2*n) = 2*a(n), a(2*n+1) = a(n) XOR a(n+1).
Other identities. For all n >= 0:
a(n) <= n.
For n >= 2, a((2^n)+1) = (2^n) - 3.
The following two identities are so far unproved:
(End)
|
|
EXAMPLE
|
In this example, binary numbers are given zero-padded to four bits.
a(2) = 2a(1) = 2 * 1 = 2.
a(3) = a(1) XOR a(2) = 1 XOR 2 = 0001 XOR 0010 = 0011 = 3.
a(4) = 2a(2) = 2 * 2 = 4.
a(5) = a(2) XOR a(3) = 2 XOR 3 = 0010 XOR 0011 = 0001 = 1.
a(6) = 2a(3) = 2 * 3 = 6.
a(7) = a(3) XOR a(4) = 3 XOR 4 = 0011 XOR 0100 = 0111 = 7.
|
|
MATHEMATICA
|
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 *)
|
|
PROG
|
(Scheme, with memoization-macro definec)
(definec (A264977 n) (cond ((<= n 1) n) ((even? n) (* 2 (A264977 (/ n 2)))) (else (A003987bi (A264977 (/ (- n 1) 2)) (A264977 (/ (+ n 1) 2))))))
;; Where A003987bi computes bitwise-XOR as in A003987.
(Python)
class Memoize:
def __init__(self, func):
self.func=func
self.cache={}
def __call__(self, arg):
if arg not in self.cache:
self.cache[arg] = self.func(arg)
return self.cache[arg]
@Memoize
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)
|
|
CROSSREFS
|
Cf. A000225, A001511, A002487, A003987, A010060, A011655, A048675, A055396, A125184, A248663, A260443, A265397, A277330.
Cf. A277700 (binary weight of terms).
Cf. A277711 (position of the first occurrence of each n in this sequence).
|
|
KEYWORD
|
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|