OFFSET
0,1
COMMENTS
OR(n, 2) + AND(n, 2) = n + 2.
OR(n, 2) - AND(n, 2) = n + 2*(-1)^floor(n/2), A004443.
a(n) = n when n = 2 or 3 mod 4 (n is in A042964). - Alonso del Arte, Feb 07 2013
LINKS
Shane Chern, T. Cai, and H. Zhong, On the cardinality and sum of reciprocals of primitive sequences, Preprint 2018; To appear in Adv. Math. (China).
Index entries for linear recurrences with constant coefficients, signature (2,-2,2,-1).
FORMULA
a(n) = n + 1 + (-1)^floor(n/2).
G.f.: ( 2-x+x^3 ) / ( (1+x^2)*(x-1)^2 ). - R. J. Mathar, Feb 27 2013
Sum_{n>=0} (-1)^n/a(n) = Pi/4 - log(2)/2 = A196521. - Peter McNair, Aug 05 2023
EXAMPLE
a(3) = 3 because OR(0011, 0010) = 0011 = 3.
a(4) = 6 because OR(0100, 0010) = 0110 = 6.
a(5) = 7 because OR(0101, 0010) = 0111 = 7.
MAPLE
with(Bits): seq(Or(n, 2), n=0..60);
MATHEMATICA
Table[BitOr[n, 2], {n, 0, 100}] (* Alonso del Arte, Feb 06 2013 *)
LinearRecurrence[{2, -2, 2, -1}, {2, 3, 2, 3}, 80] (* Harvey P. Dale, Oct 25 2016 *)
PROG
(PARI) a(n)=bitor(n, 2) \\ Charles R Greathouse IV, Feb 27 2013
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Gary Detlefs, Feb 06 2013
STATUS
approved