I found this problem in a test and could not solve it: given two arbitrary numbers, how can the number of 1 bits in the binary representation of their product be computed without computing the product itself?  The asymptotic complexity of the solution must be O(log(A+B)), where A and B are the given factors.
For example, if A and B are 3 and 7 then the product is 21. The binary representation of 21 is 10101, which has three 1 bits, so the answer is 3.
Can anyone suggest how to do this?
 
     
     
    