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

  1. x & y = 1s in both x and y
  2. 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