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”).

A330602
a(n) = a(n-1) XOR (n+1), with a(0) = 0.
1
0, 2, 1, 5, 0, 6, 1, 9, 0, 10, 1, 13, 0, 14, 1, 17, 0, 18, 1, 21, 0, 22, 1, 25, 0, 26, 1, 29, 0, 30, 1, 33, 0, 34, 1, 37, 0, 38, 1, 41, 0, 42, 1, 45, 0, 46, 1, 49, 0, 50, 1, 53, 0, 54, 1, 57, 0, 58, 1, 61, 0, 62, 1, 65, 0, 66, 1, 69, 0, 70, 1, 73, 0, 74, 1, 77, 0, 78
OFFSET
0,2
FORMULA
a(n) = a(n-1) XOR (n+1), with a(0) = 0.
From Colin Barker, Dec 19 2019: (Start)
G.f.: x*(2 + x + 3*x^2 - x^3 - x^4) / ((1 - x)^2*(1 + x)^2*(1 + x^2)).
a(n) = a(n-2) + a(n-4) - a(n-6) for n>5.
(End)
From Stefano Spezia, Jun 20 2021: (Start)
E.g.f.: ((1 + 2*x)*cosh(x) - cos(x) - sin(x) + 3*sinh(x))/2.
a(n) = (2 + n - (-1)^n*(1 + n) - A057077(n))/2. (End)
MATHEMATICA
a[0] = 0; a[n_] := a[n] = BitXor[a[n-1], n+1]; Array[a, 100, 0] (* Amiram Eldar, Dec 19 2019 *)
{0, #, 1, #+1}[[Mod[#, 4, 1]]]&/@Range@100 (* Federico Provvedi, May 11 2021 *)
LinearRecurrence[{0, 1, 0, 1, 0, -1}, {0, 2, 1, 5, 0, 6}, 80] (* Harvey P. Dale, Aug 07 2022 *)
PROG
(JavaScript) function generate (n) {
let seq = [];
for (let i = 1; i < n; i++) { seq.push(i) };
let last = 0;
return [0, ...seq.map(i => last = last ^ (i + 1))];
}
(PARI) concat(0, Vec(x*(2 + x + 3*x^2 - x^3 - x^4) / ((1 - x)^2*(1 + x)^2*(1 + x^2)) + O(x^70))) \\ Colin Barker, Dec 19 2019
CROSSREFS
Bisections are: A000035 (even part), A042963(n+2) (odd part).
Cf. A057077.
Sequence in context: A021469 A090985 A011131 * A058241 A021827 A338554
KEYWORD
base,nonn,easy
AUTHOR
Kyle West, Dec 19 2019
STATUS
approved