We are looking at question 4.1 from Elements Of Programming Interviews in Python book.

Write expressions that uses bitwise operators, equality checks and boolean operators to right propagate the rightmost set bit in X in O(1) time.

If you are applying for software engineering positions I highly recommend getting this book.

Here is the video I created which walk you through the solution.