static int x = 0;
i = 5 => x = x + MadeEasy(5);
we know (odd number & 1) is 1 and (even number & 1 is 0).
so, in MadeEasy function, k=5
count = count + (k&1) ? 1 : -1
=> count = count + (5 & 1) ? 1 : -1
=> count = 0 + 1 (since 5 & 1 gives 1 that is true.)
=> count = 1; Next K >>= 1; we know it is right shift operator (it divides k with 2^(number of shifts))
=> k = k / 2^1 => k = 5 / 2 = 2;
=> k & 1 is (2&1) which is 0. so,it gives -1. => count = 1 + (-1) = 0 and k = 2 >> 1 => k=1;
=> (1 & 1) is 1. so, it gives 1 count = 0 + 1; Now k becomes 0 and that is false in while, it returns count which is 1.
for i = 4 => k values 4,2,1 which gives -1,-1,1. so, count becomes 1-1-1+1 = 0;
for i = 3 => k values 3,1 which gives 1,1. so, count becomes 0 + 1+1 = 2;
for i = 2 => k values 2,1 which gives -1,1. so, count becomes 2-1+1 = 2;
for i = 1 => k values 1 which gives 1. so, count becomes 2 + 1 = 3;
Therefore, 1 + 0 + 2 + 2 + 3 = 8