# Counting all multiples of $n_1$ in the vicinity of $n_2\pm1$.

Consider the following graphic:

The points on the upper line, "the $12$ line", are $12$ apart while the ones on the lower line, "the $5$ line", are $5$ apart. The points on the upper line progress by $12n$ where each point's $n$ value is 1 more then the $n$ value of the previous point as in $\{12\ast1, 12\ast2, 12\ast3, ..., 12\ast k\}$. This mechanism applies to the lower line where the constant is $5$. Now, notice the two red points on the lower line which are $5\ast5$ and $5*7$, these points can also be expressed as $12n+1$ and $12n-1$. My question is, given any length of plot how does one calculate the number of points that can be expressed either as $xn-1$ or $xn+1$. The two black points on the twelve line $1$ away from the red points can also be expressed as $5n-1$ and $5n+1$. How do you count all the points on the $12$ line that are adjacent to $5n\pm1$, and visa verse the ones on the $5$ line that are $12n\pm1$?

-

You want points satisfying $$x \equiv 0 \mod 5 \\ x \equiv 1 \mod 12$$

By chinese remainder theorem, this is equivalent to $x \equiv 25 \mod 60$.

Similarly, for $$x \equiv 0 \mod 5 \\ x \equiv -1 \mod 12$$

we get $x \equiv 35 \mod 60$.

These give all the points that are on "the $5$ line" and at $1$ distance from points on "the $12$ line". The corresponding points on "the $12$ line" are given by $x \equiv 24 \mod 60$ and $x \equiv 36 \mod 60$.

-
Also, note that $36=35+1$ and $25=24+1$ and $36+25=60+1$ and $35+24=60-1$. These are not accidents. –  Thomas Andrews Jan 18 '13 at 19:51
@ThomasAndrews Thanks! I had not noticed that. –  polkjh Jan 18 '13 at 19:55