OFFSET
0,5
LINKS
Reinhard Zumkeller, Table of n, a(n) for n = 0..10000
Eric Weisstein's World of Mathematics, AND
Eric Weisstein's World of Mathematics, OR
Reinhard Zumkeller, Logical Convolutions
FORMULA
a(2*n) = 2*2^floor(log_2(n)) - 1 = A003817(n).
a(2*n+1) = 2*a(n).
EXAMPLE
a(4) = (0 AND 4) OR (1 AND 3) OR (2 AND 2) OR (3 AND 1) OR (4 AND 0) -> (000 AND 100) OR (001 AND 011) OR (010 AND 010) OR (011 AND 001) OR (111 AND 000) = 000 OR 011 OR 010 OR 011 OR 000 = 011 -> a(4)=3.
MATHEMATICA
a[n_] := BitOr @@ Table[BitAnd[k, n - k], {k, 0, n}]; Table[a[n], {n, 0, 73}] (* Jean-François Alcover, Jun 19 2012 *)
PROG
(Haskell)
import Data.Bits ((.&.), (.|.))
a086099 n = foldl1 (.|.) $ zipWith (.&.) [0..] $ reverse [0..n] :: Integer
-- Reinhard Zumkeller, Jun 04 2012
(PARI) a(n) = n++; 1<<logint(n, 2) - 1<<valuation(n, 2); \\ Kevin Ryde, Apr 11 2023
CROSSREFS
AUTHOR
Reinhard Zumkeller, Jul 09 2003
STATUS
approved