login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A182243
a(0)=0, a(n) = (a(n-1) AND n) + n.
3
0, 1, 2, 5, 8, 5, 10, 9, 16, 9, 18, 13, 24, 21, 18, 17, 32, 17, 34, 21, 40, 21, 42, 25, 48, 41, 34, 29, 56, 53, 50, 49, 64, 33, 66, 37, 72, 37, 74, 41, 80, 41, 82, 45, 88, 53, 82, 49, 96, 81, 66, 53, 104, 85, 74, 57, 112, 105, 98, 93, 88, 85, 82, 81, 128, 65
OFFSET
0,3
LINKS
Eric Weisstein's World of Mathematics, AND
FORMULA
a(0) = 0, a(n) = (a(n-1) AND n) + n, where AND is the bitwise logical AND operator.
MATHEMATICA
Join[{t = 0}, Table[t = BitAnd[t, n] + n, {n, 100}]] (* T. D. Noe, Apr 21 2012 *)
PROG
(Python)
a=0
for i in range(1, 511):
print(a, end=', ')
a &= i
a += i
(Haskell)
import Data.Bits ((.&.))
a182243 n = a182243_list !! n
a182243_list = map fst $ iterate f (0, 1) where
f (y, x) = ((x .&. y) + x, x + 1) :: (Integer, Integer)
-- Reinhard Zumkeller, Apr 23 2012
CROSSREFS
Cf. A182242.
Sequence in context: A011201 A201772 A196605 * A360898 A118119 A340253
KEYWORD
nonn,base,look
AUTHOR
Alex Ratushnyak, Apr 20 2012
STATUS
approved