A378299 Read the binary representation of n from the most to least significant bit then perform a cumulative XOR and store by reading from least to most significant bit.
0, 1, 1, 2, 1, 6, 2, 5, 1, 14, 6, 9, 2, 13, 5, 10, 1, 30, 14, 17, 6, 25, 9, 22, 2, 29, 13, 18, 5, 26, 10, 21, 1, 62, 30, 33, 14, 49, 17, 46, 6, 57, 25, 38, 9, 54, 22, 41, 2, 61, 29, 34, 13, 50, 18, 45, 5, 58, 26, 37, 10, 53, 21, 42, 1, 126, 62, 65, 30, 97, 33, 94
Offset: 0
Examples
For n = 75 a(75) = 78 because: 75 in base 2 is 1001011 and in base 2: m | x = x XOR (m AND 1) | o ---------+---------------------+---------- 1001011 | 1 = 0 XOR 1 | 1 100101 | 0 = 1 XOR 1 | 10 10010 | 0 = 0 XOR 0 | 100 1001 | 1 = 0 XOR 1 | 1001 100 | 1 = 1 XOR 0 | 10011 10 | 1 = 1 XOR 0 | 100111 1 | 0 = 1 XOR 1 | 1001110 And 1001110 in base 10: 78
Links
- Paolo Xausa, Table of n, a(n) for n = 0..16383
- Michael De Vlieger, Log log scatterplot of a(n), n = 1..2^20.
- Michael De Vlieger, Fan style binary tree showing a(n), n = 0..2^13-1, with a color function showing a(n) according to floor(log_2(a(n))).
- Index entries for sequences related to binary expansion of n
Crossrefs
Programs
-
Mathematica
A378299[n_] := FromDigits[FoldList[BitXor, 0, Reverse[IntegerDigits[n, 2]]], 2]; Array[A378299, 100, 0] (* Paolo Xausa, Dec 13 2024 *)
-
Python
def a(n): m,x,o = n,0,0 while m > 0: x ^= (m & 1) o <<= 1 o |= x m >>=1 return o print([a(n) for n in range(0,71)])
Comments