The expression of the function is given by
It is known that for any integer be expressed in the form of binary expansion: where is denate the position of the -th set bit(i.e.,bit with value 1) in the binary representation of, and is the total number of the elements in array ).For this form,the identity always holds.
Why? This is the proof process below.
Let the number be the number of digits of the number and the array be , then let the array be .
Because the intersection of and is empty, y is one’s complement of x,and then is equal to .
According to properties of bitwise AND operation,.But if update y to y+1, the result of will be different, and this is the key to .
On the one hand, if is an odd number and update to ,the first digit of is one, so the result is one, which is equal to .
On the other hand,if is a even number,the first digit of is one.Then update to ,there is a continuous carry occurring on until the next one(donate it as ),whose value is one in , of present digit position is zero.After that,this digit position will be one whose value is the same as the number ‘s.So it is easy to know that the
Based on above context, we can conclude the function , which equal to
Thus,the proof is completed.