OFFSET
0,3
COMMENTS
a(n)>=n.
LINKS
Reinhard Zumkeller, Table of n, a(n) for n = 0..10000
Eric Weisstein's World of Mathematics, XOR
Wikipedia, Bitwise operation XOR
FORMULA
a(0) = 1, a(n) = (a(n-1) XOR n) + n, where XOR is the bitwise exclusive-OR operator.
EXAMPLE
a(5) = (a(4) XOR 5) + 5 = (17 XOR 5) + 5 = 20 + 5 = 25.
MATHEMATICA
FoldList[BitXor[#, #2] + #2 &, 1, Range[100]] (* Paolo Xausa, Apr 16 2025 *)
PROG
(Python)
a=1
for i in range(1, 55):
print(a, end=', ')
a ^= i
a += i
(Haskell)
import Data.Bits (xor)
a182388 n = a182388_list !! n
a182388_list = f 0 1 where
f x y = y' : f (x + 1) y' :: [Integer] where y' = (x `xor` y) + x
-- Reinhard Zumkeller, Apr 29 2012
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Alex Ratushnyak, Apr 27 2012
STATUS
approved
