@Digvijay
I think we cant say here :-> foo(int n) it will return n+1 as ur statement ( n|1 which is nothing but n+1.) is seeming me wrong.
Bcz suppose n=11 means foo(11)
n&n=n=00001011
now n|1=00001011 | 00000001 = 00001011=n=11 itself.
so foo(11) will return 11 ; not 12.
plz correct me :)