Remainder for negative division How do you calculate the remainder for a division like: 
$$
(-a)  \mod  b,\; \mbox{ where } a<b? 
$$
For example, for $-7 \mod 26$, what will be the quotient and the remainder?
 A: The most common definition is that remainder is equal to 
$b-a$ for $a<b$
from the equation $a=quotient*b+remainder $ we see that the $quotient$ is always $-1$.
Remainder is 
$b-(a$ $mod$ $b)$ for $a>b$ 
from the same equation we get $quotient=\frac{a-b+ (a\mod b)}{b}$.
See for example this article from London University.
A: First of all, we need a precise definition of division with remainder.

Definition. Let $a$ and $b$ integers, $b\neq 0$. If there exist integers $q$ and $r$ such that $$a=bq + r,\ 0\leq r <|b|$$ we call
  $q$ quotient and $r$ remainder.
Theorem. Let $a$ and $b$ integers, $b\neq 0$. There exist unique integers $q$ and $r$ such that $$a=bq + r,\ 0\leq r <|b|.$$

To prove the existence in the above theorem, first you could consider only positive $a$ and $b$ and define $$q := \min\{ n\mid bn > a\}-1.$$ From the definition we have $$bq \leq a < b(q+1)\implies 0\leq a-bq <b$$ so define $$r:= a -bq.$$
For negative $a$ or $b$ one could do a bit of casework to get things done.
For the uniqueness part, assume $bq + r = bq' + r'$. Then we have $b(q-q') = r' - r$ and $r'-r$ is divisible by $b$. But, $0\leq r<|b|$ and $0\leq r'<|b|$ implies that $-|b|<r'-r<|b|$ and thus $r'-r = 0$. It immediately follows that $q = q'$ as well.
Thus, when we have $a= -7$ and $b=26$ we need to find $r$ and $q$ such that $$-7 = 26q + r,\ 0\leq r < 26, $$ or equivalently an integer $q$ such that $0\leq -7-26q<26$. You can easily see that $q= -1$ works and that the remainder is $r = 19$.
