PUMaC 2023 Individual A Problem 1

Let p>3 be a prime and k \geq 0 an integer. Find the multiplicity of X-1 in the factorization of

f(X)=X^{3 p^{k}-1}+X^{3 p^{k}-2}+\cdots+X+1

modulo p; in other words, find the unique non-negative integer r such that (X-1)^{r} divides f(X) modulo p, but (X-1)^{r+1} does not divide f(X) modulo p.