# Counting the distinct values of a modular mapping

Hello,
first of all, sorry if my question is either trivial or imprecise, I'm from the engineering domain :)

I need to know how many different values the following pair can take:

$\left(a\cdot i + b\cdot j\right) \bmod n_1$
$\left(c\cdot i + d\cdot j\right) \bmod n_2$

as $(i,j)$ spans $\mathbb{Z}^2$, with given integers $a$, $b$, $c$, $d$, $n_1$, $n_2$.

I know that, in case I had a single expression, i.e.

$\left(a\cdot i + b\cdot j\right) \bmod n$

the answer would be $\frac{n}{\gcd(\gcd(a,b),n)}$.

I suspect that the answer to my question looks similar.
In particular, I was trying to establish an isomorphism between $\left(\mathbb{Z}_{n_1},\mathbb{Z}_{n_2}\right)$ and $\mathbb{Z}_{n_1\cdot n_2}$, obtaining something looking like

$\left(u\cdot i + v\cdot j\right) \bmod \left( n_1\cdot n_2\right)$

so as to exploit the same result, but so far I didn't come out with anything useful.

Any clues?
Thanks!

## Answers and Replies

Related Linear and Abstract Algebra News on Phys.org
Erland
In particular, I was trying to establish an isomorphism between $\left(\mathbb{Z}_{n_1},\mathbb{Z}_{n_2}\right)$ and $\mathbb{Z}_{n_1\cdot n_2}$
But that's not true in general. For example $\left(\mathbb{Z}_2,\mathbb{Z}_2\right)$ is not isomorphic to $\mathbb{Z}_4$. In the former, all nonzero elements have order 2, while the latter has a generator of order 2.