login
A086099
a(n) = OR(k AND (n-k): 0<=k<=n), AND and OR bitwise.
6
0, 0, 1, 0, 3, 2, 3, 0, 7, 6, 7, 4, 7, 6, 7, 0, 15, 14, 15, 12, 15, 14, 15, 8, 15, 14, 15, 12, 15, 14, 15, 0, 31, 30, 31, 28, 31, 30, 31, 24, 31, 30, 31, 28, 31, 30, 31, 16, 31, 30, 31, 28, 31, 30, 31, 24, 31, 30, 31, 28, 31, 30, 31, 0, 63, 62, 63, 60, 63, 62, 63, 56, 63, 62
OFFSET
0,5
COMMENTS
a(2^n - 1) = 0, a(3*2^n - 1) = 2^n;
A086100(n) = A007088(a(n)).
LINKS
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).
a(n) = A053644(n+1) - A006519(n+1). - Ridouane Oudra, Apr 09 2023
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
Cf. A003817 (even bisection), A062383.
Cf. A086100 (in binary), A007088.
Sequence in context: A089306 A244996 A377312 * A048967 A324182 A166592
KEYWORD
nonn,nice,easy,hear,look
AUTHOR
Reinhard Zumkeller, Jul 09 2003
STATUS
approved