I'm having a problem understanding this equation in modular arithmetic I have tried searching the internet but I haven't found a solution, I hope you can help.
$a = k(26) + b\; \text{ for }a > 0\:$ (26 is just what he uses in the book as he is explaining the Caesar cipher)
The author then goes on to say that even if $a$ were negative, we could easily find a positive number $b$ in the set $\{1,2,\ldots,26\}$ such that $a$ is congruent to $b$ by dividing the positive number $-a$ by $26$, obtaining:
$-a = q(26) + r = (q+1)26 - (26-r),\quad q\ge 0, \enspace 0\le r<26$.
My question is: How did he get to that equation, I seem to have tried anything, it might be that I am really tired, but I have to know the answer before I sleep.
Thank you
We usually write
$$a = k(26) + b\; \text{ for }a > 0\:$$ as $$a = 26 \cdot k + b\; \text{ for }a > 0\:$$ where $k$ is the quotient when divided by 26 and $b$ is the remainder.
Now look at
$$-a = q(26) + r = (q+1)26 - (26-r),\quad q\ge 0, \enspace 0\le r<26.$$
it is used to find the representative of a negative $-a$ number
$$-a = 26\cdot q + r = 26 (q+1) - (26-r),\quad q\ge 0, \enspace 0\le r<26.$$
The trick is, add and subtract 26. Take the $\mod 26$ in the last equation. And, the shortest way is $26-a$ if $a < 26$.