Reverse modulo operation Say I am given a number $n$ as well as a range from $0$ to $L$.
I now want to find $a$ and $b$ so that $a \mod b = n$.
It is important that $a$ and $b$ are smaller the $L$ for every $n$.
How can I find a random valid combination (often there are multiple solutions) for $a$ and $b$ that satisfies every $n$ whereas $0\le n\le L?$
 A: $a\mod{b} = n$ implies that $a$ can be expressed as $$a = k\cdot b+n$$for some integer $k$. That implies that $b\;|\;a-n $, or that $a-n$ is a multiple of $b$. So, the way to generate every combination is to take each possible $b$ in turn, compute all of its multiples less than or equal to $L-n$, and then adding $n$ to each one to generate each possible $a$ for that $n$.
A: For $n\lt L$, take $$a=n, b\in\{n+1,n+2,\dots,L\}$$
If $n=L$, it is impossible to find such a pair as anything $\bmod b$ must be $< b$.
For some sort of randomization, pick $a=n$, and randomly pick $b$ from $\{n+1,n+2,\dots,L\}$.
A: if $b > 1$ and if $a \mod b \equiv k$ then $a \mod b \not \equiv k + 1$ and $a \mod b \not \equiv k-1$.  So if you want $a \mod b \equiv n$ for EVERY $n; 0 \le n \le L$ we must either have $L = 0$ or $b =1$.  (And $b = 1$ then $anything \mod 1\equiv anything else$ because $1$ divides the difference between any two integers.)
So to find a "random valid combination"  (I'm not sure what that means) you can (must) have $b = 1$ and $a$ may be anything.
====
Maybe you didn't mean every $n$ and you just meant for a specific $n$.
If so then if you randomly pick $a$ then to have $a \mod b \equiv n$ we must have $|a - n| = k*b$ for some $k$.  So $b$ may be any factor of $|a-n|$.
[So for instance if $L =95$ and $n = 51$ and $a = 3$ then $3\mod b \equiv 51 \iff b|(51-3)$ so $b$ can be any factor of $48$ i.e. $1,2,3,4,6,8,12,16,24,48$]
If you randomly pick $b$ then to have $a \mod b \equiv n$ we must have $|a-n| = k*b$ for some $k$. So for we can let $a = n\pm bk$ for all $k$.  
Or in other words.  $a\mod b \equiv n \iff n\mod b \equiv a$ so just let $a = (n\mod b) + k*b$ for all $k$.
[So for instance if $L = 95$ and $n = 51$ and $b = 7$ then $n\equiv 2 \mod b$ so we can have $a = 2,9,16,..44, 51, 58,..., 72,79,86,93$.]
