Let's assume I am given a positive integer $n$, as well as an upper limit $L$.
How could one find all, or at least one, possible solutions for $a$ and $b$ such that ${a \mod b = n}$ where as $0 <=a, b <= L$?
Let's assume I am given a positive integer $n$, as well as an upper limit $L$.
How could one find all, or at least one, possible solutions for $a$ and $b$ such that ${a \mod b = n}$ where as $0 <=a, b <= L$?
Assuming you mean $n$ to be the remainder of $\frac{a}{b}$, you could iterate over all $n< b \leq L$ and compute all $a = n+ kb$ for $k\geq 0$ and $a\leq L$.
Edit: here is a worked example. Suppose $n=2$ and $L=5$.
$a \mod b$ will be smaller than $b$, so we must start with $b>2$.
For $b=3$, we can try: \begin{align}a = 2 + 0\cdot 3 = 2 \\a = 2+1\cdot 3 = 5\end{align} and these are the only values of $a\leq 5$.
For $b=4$, $a=2+0 cdot 4 = 2$ is our only result and for $b=5$, $a=2+0\cdot 5 = 2$ is our only result.
This gives us solution set $\{(2,3), (5,3), (2,4), (2,5)\}$
For each $b \in \mathbb{N}$, we have $\{a \in \mathbb{Z} : a \equiv n \pmod b\} = \{n+kb : k \in \mathbb{Z}\}$. Then note that $0 \leq n+kb \leq L$ iff $-\frac{n}{b} \leq k \leq \frac{L-n}{b}$.