I have attached the expected 32-bit solution as well as the 64-bit on 32-bit machine solution. Note that in the 64-bit solution, we have a slightly simplified case of 64-bit division, since we can assume that the denominator, n+1, is 32 bits, and thus we can assume that the remainder is 32 bits as well.