Question: I need a function in Standard ML: dividemod : int * int --> int * int. The algorithm: subtract denominator from numerator until numerator is
I need a function in Standard ML:
dividemod : int * int --> int * int.
The algorithm: subtract denominator from numerator until numerator is less than the denominator, at which point numerator is the remainder, and the number of total subtractions is the quotient.
This function should satisfy this:
For all natural numbers n and d such that d > 0, there exist natural numbers q and r such that divmod (n, d) $ (q, r) and qd + r = n and r
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
