OFFSET
0,1
COMMENTS
a(n) = n if n is congruent to (4, 5, 6, 7) mod 8. In general, (n OR 2^k) has the closed form n + 2^k * floor( ( (n+2^k) mod 2^(k+1) )/2^k ).
FORMULA
a(n) = (n+4) - (n AND 4).
a(n) = (n XOR 4) + (n AND 4).
a(n) = n + 4*floor(((n+4) mod 8)/4).
From Bruno Berselli, Jul 01 2014: (Start)
a(n) = 2 + n + 2*(-1)^floor(n/4).
G.f.: (4 - 3*x + x^5)/((1 - x)^2*(1 + x^4)). (End)
Sum_{n>=0} (-1)^n/a(n) = (2*sqrt(2)-1)*Pi/8 - 3*log(2)/4. - Amiram Eldar, Aug 07 2023
EXAMPLE
a(10) = 14 because 10 in binary is 1010 and 4 is 0100, and 1010 OR 0100 = 1110, which is 14 in decimal.
a(11) = 15 because 11 in binary is 1011 and 4 is 0100, and 1011 OR 0100 = 1111, which is 15 in decimal.
a(12) = 12 because 12 in binary is 1100 and 4 is 0100, and 1100 OR 0100 = 1100, which is 12 in decimal.
MAPLE
with(Bits): seq(Or(n, 4), n = 0..60);
MATHEMATICA
Table[BitOr[n, 4], {n, 0, 63}] (* Alonso del Arte, Jul 01 2014 *)
PROG
(Magma) [BitwiseOr(n, 4): n in [0..70]]; // Bruno Berselli, Jul 01 2014
(Python)
def A244586(n): return n|4 # Chai Wah Wu, Jan 18 2023
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Gary Detlefs, Jun 30 2014
EXTENSIONS
Some terms corrected by Bruno Berselli, Jul 01 2014
STATUS
approved