For what powers $k$ is the polynomial $n^k-1$ divisible by $(n-1)^2$? [closed]

Let us write $m=n-1$ so we wish to show $$m^2|(m+1)^k-1 \Rightarrow m|k$$

Now, using the Binomial Theorem, $$(m+1)^k-1=m^k+\cdots + km$$ all terms are divisible by $m^2$ except the last and so we see $m^2|km$ implies $m|k$.


Hint: Congruence notation helps a lot here. We want to show that $n-1$ divides $n^{k-1}+\cdots +1$ if and only if $k$ is of suitable shape. Work modulo $n-1$, and you will get a one line proof.


Hint $\ $ Apply the following numerical form of the double root test for a polynomial $\,f(n)\,$ with integer coefficients

$$\rm\begin{eqnarray} &&\!\!\!\!\!\! (n\!-\!1)^2 |\ f(n)\!\!\!\!\!\!\!\\ \iff\ && n\!-\!1\ |\ f(n)\ &\rm and\ \ & n\!-\!1\ \big|\ \dfrac{f(n)}{n\!-\!1}\\[.5em] \iff\ && \color{#c00}{f(1) = 0} &\rm and&n\!-\!1\ \big|\ \left[\dfrac{f(n)-\color{#c00}{f(1)}}{n\!-\!1}\right]_{\large\, n\:=\:1}\! = f'(1) \\ \end{eqnarray}$$

So $\,f(n) = n^k-1\,\Rightarrow\,f(1)=0,\,$ and $\ f'(n) = k n^{k-1}\!\Rightarrow\,f'(1) = k,\,$ so the above criterion is $$\,(n\!-\!1)^2\mid n^k-1\iff n\!-\!1\mid f'(1) = k\qquad\qquad$$