Concerning a modification of the division with remainder

19 Views Asked by At

I just did the following exericse:

Prove that for given intergers $a$ and $b$ with $b>0$ holds:

There are unique integers $q$ and $r$ such that $a = qb+r$ and $-b/2 < r \le b/2$.

I did the following:

$$-b/2 < r = a-qb \le b/2$$ $$\implies \frac{a}{b} + \frac{1}{2} > q \ge \frac{a}{b}-\frac{1}{2} $$ $$\implies q = \lceil{ \frac{a}{b} + \frac{1}{2}\rceil}$$

I am insecure about the ceil in the end, could you tell me if I am right?

2

There are 2 best solutions below

0
On BEST ANSWER

I find the argument below simpler.

We have $a = Qb+R$, with $0 \le R < b$.

If $R \le b/2$, then take $q=Q, r=R$.

If $R > b/2$, then take $q=Q+1, r=R-b$. Then $-b/2 < R <0 < b/2$.

0
On

If there are two $q$s such that $$a=bq_1+r_1$$and $$a=bq_2+r_2$$we have $$|r_1-r_2|=|q_1-q_2|b\ge b$$which is impossible since $-\dfrac{b}{2}<r_1,r_2\le\dfrac{b}{2}$ then $q_1=q_2$ and so is $r_1=r_2$