Your question is Divide Integers Without Division. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
The Fannie Mae Desktop Underwriter (DU) calculation layer needs integer division for bounded values, but the arithmetic primitive cannot use division, modulo, or multiplication operators. Implement a function that returns the quotient and remainder of two integers.
The quotient must truncate toward zero. The remainder must have the same sign as the dividend, satisfying dividend = divisor * quotient + remainder mathematically. You may use addition, subtraction, comparisons, bit shifts, bitwise operations, and unary negation. The divisor is guaranteed to be nonzero.
Implement divide_integers(dividend, divisor).
dividend and divisor.[quotient, remainder]./, //, %, or multiplication in the implementation.def divide_integers(dividend, divisor):