<s>[INST] 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$
 [/INST] 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)$$
</s>