Let q be a positive integer such that $q \geq 2$ and such that for any integers $a$ and $b$, if $q|ab$ then $q|a$ or $q|b$.Show that $q$ is a prime number.
It will probably be proved by contradiction, so I assumed $q$ is a prime, i.e $q=xy$ where $x$ and $y$ are some positive integers and not equal to $1$ or $q$, and tried to a contradiction but I couldn't figure out how to proceed from here.