I'm trying to prove/disprove the following:
If $a,b,x$ be three integers (where $x\neq 0$) such that $x\mid a,b$ and $n$ be a positive integer, then the following congruence holds:
$$a\equiv b\pmod{n}\iff a/x\equiv b/x\pmod{n/\gcd(x,n)}$$
My intuition says it's true and below here is my attempt at a proof. Can the community verify if it's correct? Thanks.
Proof.
Necessity: If $a/x\equiv b/x\pmod{n/\gcd(x,n)}$, then we can write $(a-b)/x=nl/\gcd(x,n)$ for some integer $l$, so that we have,
$$(a-b)/n = lx/\gcd(x,n) = l\ast (x/\gcd(x,n))$$
Since $\gcd(x,n)\mid x$ by definition of $\gcd$, we see that $(a-b)/n$ is an integer and hence $a\equiv b\pmod n$
Sufficiency: If $a\equiv b\pmod n$, then we can write $a-b=np$ for some integer $p$, so that we have,
$$\begin{align}a-b=np&\implies (a-b)\gcd(x,n)=np\gcd(x,n)\\&\implies \frac{(a-b)\gcd(x,n)}{nx}=\frac{p\gcd(x,n)}{x}\end{align}$$
By Bezout's Lemma, there exists integers $b_1,b_2$ such that $\gcd(x,n)=b_1x+b_2n$, so we have,
$$\frac{(a-b)\gcd(x,n)}{nx}=\frac{p(b_1x+b_2n)}{x}=pb_1+\frac{b_2np}{x}=pb_1+b_2\frac{a-b}{x}$$
Since $x\mid a,b$, we have $x\mid a-b$ and so we can write $a-b=xq$ for some integer $q$. Then,
$$\frac{(a-b)\gcd(x,n)}{nx}=pb_1+qb_2$$
So, we conclude that $\dfrac{(a-b)\gcd(x,n)}{nx}$ is an integer, i.e, $\dfrac{(a-b)/x}{n/\gcd(x,n)}$ is an integer, so $\frac ax-\frac bx$ is divisible by $n/\gcd(x,n)$ which shows that $a/x\equiv b/x\pmod{n/\gcd(x,n)}$