OFFSET
1,4
LINKS
Andrew Howroyd, Table of n, a(n) for n = 1..10000
Rémy Sigrist, C program for A338824
Index entries for linear recurrences with constant coefficients, signature (0,1,0,1,0,-1).
FORMULA
a(2*n) = 2*n-2 for any n > 0.
a(4*n+1) = 0 for any n >= 0.
a(4*n+3) = 1 for any n >= 0.
a(n) OR a(n+1) = A116966(n-2) for any n > 1.
G.f.: x^3*(1 + 2*x - x^2 + 2*x^3)/((1 - x)^2*(1 + x)^2*(1 + x^2)). - Andrew Howroyd, Nov 18 2025
EXAMPLE
The first terms, alongside a(n) OR a(n+1), are:
n a(n) a(n) OR a(n+1)
-- ---- --------------
1 0 0
2 0 1
3 1 3
4 2 2
5 0 4
6 4 5
7 1 7
8 6 6
9 0 8
10 8 9
11 1 11
12 10 10
MATHEMATICA
Block[{a = {0, 0}, b = {0}}, Do[Block[{k = 0, m}, While[! FreeQ[b, Set[m, BitOr @@ {a[[-1]], k}]], k++]; AppendTo[a, k]; AppendTo[b, m]], {i, 3, 76}]; a] (* Michael De Vlieger, Nov 12 2020 *)
PROG
(C) // See Links section.
(PARI) a(n) = if(n%2==0, n-2, bittest(n, 1)); \\ Andrew Howroyd, Nov 18 2025
CROSSREFS
KEYWORD
nonn,base,easy
AUTHOR
Rémy Sigrist, Nov 11 2020
STATUS
approved
