Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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|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
add comment

1 Answer 1

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|improve this answer
add comment

Your Answer

 
discard

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.