# Puzzle (1): Explaining a pattern in multiplication graphs modulo $m$

In the plots of multiplication graphs $$\mu^n_m(k) = kn\ \%\ m$$ (with $$a\ \%\ b$$ meaning $$a$$ modulo $$b$$) the dots are undeniably arranged along parallel lines with a well-defined common slope $$\alpha$$ given by

$$\tan(\alpha) = \frac{\mu^n_m(k_0) - n}{k_0 - 1}$$

with $$k_0$$ the number $$k$$ greater than $$1$$ which minimizes $$(k - 1)^2 + (\mu^n_m(k) - n)^2$$:

[click image to enlarge]

These lines may have equal or different lengths – i.e. numbers of dots lying on them (possibly only two) – but in any case there is a specific number $$\#L^n_m$$ of them, e.g. $$\#L^n_{50}=n$$ for $$n < 10$$, $$n \neq 8$$ – or $$\#L^{10}_{50}=5$$.

My question is:

(How) can the number $$\#L^n_m$$ of these lines be given in a closed expression depending on $$n$$ and $$m$$?

The following expression at least gives correct results when all lines have equal length. In other cases, it gives numbers that are systematically too small, e.g. $$\#L^{8}_{50}=6$$ (instead of $$7$$) or $$\#L^{9}_{50}=5$$ (instead of $$9$$):

$$\#L^n_m= \begin{cases} k_0 - 1 & \text{if } |\tan(\alpha)| < 1\\ |\mu^n_m(k_0) - n| & \text{otherwise} \\ \end{cases}$$

or equivalently

$$\#L^n_m= \operatorname{max}\{k_0 - 1, |\mu^n_m(k_0) - n|\}$$

Is there a chance to solve this puzzle? (Its motivation will hopefully become clear in a follow-up question concerning quadratic residues modulo $$m$$, so please stay tuned.)