a. Prove: If a and d are positive integers and q and r are integers such that a = dq + r and 0 < r < d, then −a = d(−(q + 1)) + (d − r ) and 0 < d − r < d.
b. Indicate how to modify Algorithm 4.8.1 to allow for the input a to be negative.
Reference:
[Given a nonnegative integer a and a positive integer d, the aim of the algorithm is to find integers q and r that satisfy the conditions a = dq + r and 0 ≤ r < d. This is done by subtracting d repeatedly from a until the result is less than d but is still nonnegative.
0 ≤ a − d − d − d −· · ·−d = a − dq < d.
The total number of d’s that are subtracted is the quotient q. The quantity a − dq equals the remainder r .]
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.