We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
we dont need to & all numbers from a to b..
Just a&(a+1)&(a+2)&(a+4)&(a+8)&(a+16)&(a+32)&(a+64) and so on. As a digit at each place will be surely flipped after 2^(its position) consecutive numbers. We just need to be sure of a zero somwhere so that we can put a zero at same place in our answer. This method will take maximum of 32 iterations.
eg: 11 20
11&12&13&15&19 Thats it
AND Product
You are viewing a single comment's thread. Return to all comments →
we dont need to & all numbers from a to b.. Just a&(a+1)&(a+2)&(a+4)&(a+8)&(a+16)&(a+32)&(a+64) and so on. As a digit at each place will be surely flipped after 2^(its position) consecutive numbers. We just need to be sure of a zero somwhere so that we can put a zero at same place in our answer. This method will take maximum of 32 iterations. eg: 11 20 11&12&13&15&19 Thats it