<s>[INST] If $p$ and $q$ are primes such that $q \mid {\frac{x^p-1}{x-1}}$ then prove that $q\equiv 1 \pmod{p}$ or $q\equiv 0 \pmod{p}$. 
QUESTION: If $p$ and $q$ are primes such that $$q \mid {\frac{x^p-1}{x-1}} ,  (x\in\Bbb{N}, x>1)$$ then prove that $q\equiv 1 \pmod{p}$ or $q\equiv 0 \pmod{p}$.


MY ANSWER: I came across this lemma, but couldn't prove the second part properly. Here's what I did -
By Fermat's Little Theorem we know that $x^p\equiv{x}\pmod{p}$. Therefore, $$\frac{x^7-1}{x-1}\equiv\frac{x-1}{x-1}=1\pmod{7}$$ Therefore, $q\equiv{1}\pmod{7}$.
Now, I cannot prove that $q\equiv{0}\pmod{7}$. Not simultaneously ofcourse, I know that ..
Here's my try -
We can write the above equation as $$x^6+x^5+x^4+x^3+x^2+x+1$$ But what after this? Even if I chose $q=7$, it does not divide the above equation for all values of $x$. Say $x=7$, then the equation can be rewritten as $$7^6+7^5+7^4+7^3+7^2+7+1$$ and $$7\nmid{7^6+7^5+7^4+7^3+7^2+7+1}$$ So, how do I rigorously prove that $q\equiv{0}\pmod{p}$ ? Or, for which cases is this true?
Any help will be much appreciated. Thank you :)

EDIT: Terrible Mistake :P The first proof of $q\equiv{1}\pmod{7}$ is wrong. So, now I am left with a full question to be proved °_°

 [/INST] Generalizing this answer first suppose that $q \not \equiv 1\pmod{p}$ so that $\gcd(q-1, p) =1$. Then there exists integers $n,m$ such that $pn + (q-1)m =1$ by Bezout's lemma. Then we have $$x \equiv x^{pn +(q-1)m} \equiv (x^p)^n(x^{q-1})^m \equiv 1 \pmod{q} $$
by Fermat's little theorem and the fact that $q|x^p-1.$
Hence $$\frac{x^p-1}{x-1} = 1+x+\dots+x^{p-1} \equiv p \pmod{q}.$$ This shows that $q=p$. The contrapositive says $q \ne p$ implies $q \equiv 1 \pmod{p}$, so we're done since either $q=p$ or $q \ne p$.
</s>