A182242 a(0)=0, a(n) = (a(n-1) + n) AND n.
0, 1, 2, 1, 4, 1, 6, 5, 8, 1, 10, 1, 12, 9, 6, 5, 16, 1, 18, 1, 20, 1, 22, 5, 24, 17, 10, 1, 28, 25, 22, 21, 32, 1, 34, 1, 36, 1, 38, 5, 40, 1, 42, 1, 44, 9, 38, 5, 48, 33, 18, 1, 52, 33, 22, 5, 56, 49, 42, 33, 28, 25, 22, 21, 64, 1, 66, 1, 68, 1, 70, 5, 72, 1
Offset: 0
Links
- Reinhard Zumkeller, Table of n, a(n) for n = 0..10000
- Eric Weisstein's World of Mathematics, AND
- Wikipedia, Bitwise operation AND
Crossrefs
Cf. A182243.
Programs
-
Haskell
import Data.Bits ((.&.)) a182242 n = a182242_list !! n a182242_list = map fst $ iterate f (0,1) where f (y,x) = ((x + y) .&. x, x + 1) :: (Integer,Integer) -- Reinhard Zumkeller, Apr 23 2012
-
Mathematica
Join[{t = 0}, Table[t = BitAnd[(t + n), n], {n, 100}]] (* T. D. Noe, Apr 21 2012 *)
-
Python
a=0 for i in range(1,511): print(a, end=',') a += i a &= i
Formula
a(0)=0, a(n)=(a(n-1)+n) AND n, where AND is the bitwise logical AND operator.
Comments