Why ans is 3 it shuld be 20-6+0=14 and in 25 line if i use if(i&1) shuld it be right please let me know how inline 25 it is checking odd or even?

hey @kailash_01 odd numbers when converted to binary form end with 1 and even number dont
2 -> 10
3 -> 11
4 -> 100
5 -> 101
So when we take bitwise and with 1 if a number has set bit in the end( i.e 1 in the end in binary representation) the value after and with become 1 else it’ll become zero thats how it is checking odd or even

why ans is 3 it shuld be 20-6+0=14

@kailash_01 please specify for which value of n answer should be 14.