For how many positive integers $n$ is $4^n − 1$ a prime number? This was the initial question and one of the methods to work it out include this:
The second method uses the fact when $n$ is a positive integer $x − 1$ is a factor of $x^n − 1$,
since, for $n ≥ 2$,
$$x^n − 1 = (x − 1)(x^{n−1} + x^{n−2} + \ldots + x + 1).$$
Hence, putting $x = 4$, we deduce that, for each positive integer $n, 3$ is a factor of $4^n − 1$. Therefore $4^n −1$ is not prime except when $n = 1$ and $4^n −1 = 3$. So there is just one positive integer $n$ for which $4^n − 1$ is a prime number.
However, I don't understand the initial method and how they deduced that $x-1$ is a factor of $x^n - 1$
 A: For the question at hand, if $P(x)$ is a polynomial and $P(r)=0$, then $P(x)=(x-r)Q(x)$ for some polynomial $Q$. If the coefficients of $P$ and $r$ are all integers, then the coefficients of $Q$ are also all integers.
The specific case of $x^n-1$ might be best understood by example:
$$\begin{align}
(x-1)(x^3+x^2+x+1)
&=(x-1)x^3+(x-1)x^2+(x-1)x+(x-1)\\
&=(x^4-x^3)+(x^3-x^2)+(x^2-x)+(x-1)\\
&=x^4+(x^3-x^3)+(x^2-x^2)+(x-x)-1\\
&=x^4-1
\end{align}$$
The key step is the "telescopic" rearrangement of the parentheses.  This is a standard technique (aka trick) when working with sums and series; you'll run into it again and again. (The term "telescopic" refers to old-style spyglasses, like you see in pirate movies, which collapse down to compact form.)
Another, possibly easier, way of seeing that $n=1$ is the only exponent for which $4^n-1$ is prime:
$$4^n-1=2^{2n}-1=(2^n-1)(2^n+1)$$
A: Knowing that $x-1$ is a factor of $x^n-1$ is somewhat a matter of experience. It comes up often in various problems or theorems, and it's something you'll get used to. A couple of ways to look at it: 


*

*Recall that $x^2-1 = (x-1)(x+1)$. The identity in your question is a generalization of this.

*Think of the geometric formula $1+x+\ldots+x^n = \frac{1-x^{n+1}}{1-x}$. Multiplying both sides by $1-x$ gives you the identity.

A: 
I don't understand the initial method and how they deduced that $x-1$ is a factor of $x^n - 1$

Most likely they didn't deduce it but remembered it. It's a standard and elementary result (the sum of a geometric progression) that $$\sum_{i=0}^n r^i = \frac{r^{n+1}-1}{r-1}$$
The fact that $x-1$ is a factor of $x^n - 1$ also follows immediately from a well-known identity of cyclotomic polynomials, $$x^{n}-1 = \prod _{d\mid n}\Phi _{d}(x)$$ since $\Phi_1(x) = x - 1$.
