A182388 a(0) = 1, a(n) = (a(n-1) XOR n) + n.
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
Examples
a(5) = (a(4) XOR 5) + 5 = (17 XOR 5) + 5 = 20 + 5 = 25.
Links
- Reinhard Zumkeller, Table of n, a(n) for n = 0..10000
- Eric Weisstein's World of Mathematics, XOR
- Wikipedia, Bitwise operation XOR
Programs
-
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
-
Mathematica
FoldList[BitXor[#, #2] + #2 &, 1, Range[100]] (* Paolo Xausa, Apr 16 2025 *)
-
Python
a=1 for i in range(1,55): print(a, end=', ') a ^= i a += i
Formula
a(0) = 1, a(n) = (a(n-1) XOR n) + n, where XOR is the bitwise exclusive-OR operator.
Comments