The generalized version of Euclid's lemma states that if $k|mn$ and that $\gcd(k, m) = 1$ then $k|n$. However, I noticed an alternative way of proving questions such as: if $2|n$ and $3|n$ show $6|n$ by getting $n = 3p = 2q$ for some integers $p, q$ and considering $3n - 2n = n = 3(2q) - 2(3p) = 6(p - q)$ and as $p - q$ is an integer we are done. This works for larger problems such as getting $42|n$ from $2|n$, $3|n$ and $7|n$ by considering $21n - 14n - 6n = n = 21(2p) - 14(3q) - 6(7r) = 42(p - q - r)$.
What is this technique called? Does it always work? Can you point me in the right direction?