login
a(0) = 0; for n >= 1, a(n) = result of inverting s-th bit (from left) in n, where s is the number of ones in the binary representation of n.
4

%I #9 Jul 23 2019 04:22:52

%S 0,0,0,2,0,7,4,6,0,13,14,9,8,15,12,14,0,25,26,23,28,17,18,21,16,29,30,

%T 25,24,31,28,30,0,49,50,43,52,45,46,35,56,33,34,47,36,41,42,45,32,57,

%U 58,55,60,49,50,53,48,61,62,57,56,63,60,62,0,97,98,83,100,85,86,79,104,89,90,67,92,69,70,75,112,65,66,91,68,93,94,83,72,81,82,95,84,89,90,93,64,113,114,107,116

%N a(0) = 0; for n >= 1, a(n) = result of inverting s-th bit (from left) in n, where s is the number of ones in the binary representation of n.

%C Iterations of a(n) always reach 0 (cf. A326732), see Problem 5 of IMO 2019.

%H International Mathematical Olympiad, <a href="https://www.imo-official.org/problems.aspx">Problem 5 of IMO 2019</a>.

%F For n>=1, a(n) = n XOR 2^(A029837(n)-A000120(n)).

%F For n>=1, a(n) = 0 iff n is a power of 2.

%o (PARI) A326731(n) = if(n==0,return(0)); my(b=binary(n)); bitxor(n,2^(#b-vecsum(b)));

%Y A variant of A326729.

%Y Cf. A000120, A029837, A326730, A326732.

%K nonn,base

%O 0,4

%A _Max Alekseyev_, Jul 22 2019