This problem is coming from an exam review.
Let $p$ be a prime number and let $\mathbb{Z}_p$ denote the set of all $x\in \mathbb{Q}$ which can be written as fractions whose denominator is not divisible by $p$.
Show that if $x \in \mathbb{Q}$, then at least one of $x$ or $x^{-1}$ is in $\mathbb{Z}_p$.
This first part of the problem says to show $\mathbb{Z}_p$ is a subring of $\mathbb{Q}$. I have shown that $\mathbb{Z}_p$ is a subring by verifying that its closed under addition and multiplication, and it also contains $-1$.
For the part that I am stuck on I think the method would be to proceed by cases but I cant seem to come up with them. What i do know is that if we let $x=a/b$ for some integers $a,b$ the claim is obvious when either $a$ or $b$ is $1$ since no prime $p\mid 1$.
Two other pieces of information I can think of are that for simplicity we can assume $\gcd(a,b)=1$ and $\gcd(p,b)=1$ or $\gcd(p,a)=1$, but I cant seem to put these things together into one proof.
Any help is appreciated! Thanks.