login
A182388
a(0) = 1, a(n) = (a(n-1) XOR n) + n.
1
1, 1, 5, 9, 17, 25, 37, 41, 41, 41, 45, 49, 73, 81, 109, 113, 113, 113, 117, 121, 129, 169, 213, 217, 217, 217, 221, 225, 281, 289, 349, 353, 353, 353, 357, 361, 369, 377, 389, 457, 521, 585, 653, 721, 809, 817, 845, 913, 977, 1041, 1109, 1177, 1249
OFFSET
0,3
COMMENTS
a(n)>=n.
LINKS
Eric Weisstein's World of Mathematics, 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
Sequence in context: A054278 A210978 A211434 * A080335 A351837 A089109
KEYWORD
nonn,base
AUTHOR
Alex Ratushnyak, Apr 27 2012
STATUS
approved