I have two natural numbers $2\le b\lt a$. I want to know the least natural number $x_1$ such that $\frac{xa}{b}$ gives a remainder of $1$, and the least natural number $x_2$ such that the remainder is $b-1$ (I'm looking for a formula, not an algorithmic procedure).
In other words, that
$$ \frac{x_1a}{b}-\left\lfloor\frac{x_1a}{b}\right\rfloor=\frac{1}{b}\\ \frac{x_2a}{b}-\left\lfloor\frac{x_2a}{b}\right\rfloor=\frac{b-1}{b}\\ $$
Assume that $a$ is not divisible by $b$, so that both $x$ exist.
Under that assumption, I know that $x_1,x_2\in [1, \ldots, b - 1]$ because all possible remainders from $0$ up to $b-1$ happens exactly once when the multipliers goes from $1$ to $b$.
For example, for $\frac{19}{7}$ iterating a multiplier $x$ over $1, 2, \ldots, 7$ gives the following list of remainders:
$$ 5 \quad 3\quad 1\quad 6\quad 4\quad2\quad 0 $$
where the position ocuppied by the remainder $1$ ($x_1=3$ in this case), is the "step size" of the remainder list, because it is the number of forward positions, moving in a circular fashion, to reach the next remainder ($2$ appears three positions later, 3, other three positions later, 4, other three positions later, and so on).
About $x_2$, I know that $x_2=mod(x_1(b-1), b)$, but that's not a very useful expression that I could use comfortably in other equations that I'm working on, so I wonder if there's a way to express $x_2$ that doesn't involve the explicit use of modular arithmetic.