To be direct the simple average in math is but we can also do it using
now lets try to prove it
If you forgot bitwise operators
- x & y = 1s in both x and y
- x^y = 1s exclusively in x and y ( contains both 1 and 0 )
Lets find out x which is 1s in both x and y + 1s in x