$n$ is prime if $1+x+x^2+\dots+x^{n-1}$ is prime I came across this question in a number theory textbook:

Let $x$ and $n$ be positive integers such that $1+x+x^2+\dots+x^{n-1}$ is prime. Then show that $n$ is prime.

I reasoned that this proof would require Fermat's Little Theorem, and put $1+x+x^2+\dots+x^{n-1} = \frac{x^n-1}{x-1}$, but was unable to continue.

What perplexes me most, however, is a shoddy argument I found in the 'solutions' section of the book. There the author argued that $1+x+x^2+\dots+x^{n-1} = \frac{x^n-1}{x-1} \Rightarrow x-1=1 \Rightarrow x=2.$ This was given without any explanation and I don't know what to make of it. 
If that step is correct, why so?

If $x=1$, then $1+x+\ldots+x^{n-1}$ is simply $n$ and we are done. So assume $x\gt 1$.
Suppose that $n$ is composite, $n=ab$ with $a\geq 2,b\geq 2$. Then we have $\frac{x^n-1}{x-1}=AB$ where $A=\frac{x^n-1}{x^a-1}=1+x^a+(x^a)^2+\ldots+(x^a)^{b-1}$ and $B=\frac{x^a-1}{x-1}$. So $\frac{x^n-1}{x-1}$ is composite.
