Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

how can I do a formal proof of the following description:

$a\;div\;b = \begin{cases} \lfloor \frac{a}{b} \rfloor &\text{ if }b>0\\ \lceil \frac{a}{b} \rceil &\text{ if }b<0 \end{cases}\\$

It seems pretty straight forward as $a$ div $b$ is defined as $q$ from the expression $a=q b + r$, where r has to be a positive integer smaller than b.

share|cite|improve this question
I believe is $a=qb+r$ with $0\leq r<b$ positive integer. – P.. Dec 10 '12 at 20:48
Just use the definition of the floor function. – Adeel Dec 10 '12 at 20:48
Thank you @Pambos; you're right. @Adeel - well I know what floor and ceil functions do, but even then it seems trivial that q has to be largest integer not greater than the quotient (if b>0) and the otherway around for b<0... – smihael Dec 10 '12 at 20:49
up vote 2 down vote accepted

If $b\mid a$ is easy. So assume that $b\nmid a$.

Let $k$ be the largest integer that is smaller to $\dfrac{a}{b}$, i.e. $k$ is the integer with the property $k<\dfrac{a}{b}<k+1$.
If $b>0$ then for $0<s=\dfrac{a}{b}-k<1$ we have $a=kb+sb$ and $0 <sb<b$. Therefore $a \text{ div } b=k=\lfloor\dfrac{a}{b}\rfloor$.
If $b<0$ then for $0<s=k+1-\dfrac{a}{b}<1$ we have $a=(k+1)b-sb$ and $0 <-sb<b$. Therefore $a \text{ div } b=k+1=\lceil\dfrac{a}{b}\rceil$.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.