I understand that the bitwise and operator (&
) is equivalent to a product of two bit values. When would I use it?
Please also help me understand what num&1
does in the code below:
def func(num):
n = 1 + func((3*num+1) if num&1 else (num>>1))
return n