I came across the below snippet for finding out the numbers in range[M,N] having odd divisors :
def printOddFactorNumber(n, m):
for i in range(n, m + 1):
# Check if the number is not a power of two
if ((i > 0) and ((i & (i - 1)) != 0)):
print(i, end = " ")
N = 2
M = 10
printOddFactorNumber(N, M)
The logic is, the function prints all numbers which are not the power of 2. This found by performing & operation between the current number and the previous one. Can someone explain what does & mean between two integers? And the math behind how i&(i-1)!=0 means i is not power of 2 ?