In my lecture notes of algebraic number theory they are dealing with the polynomial $f=X^3+X+1, $ and they say that
If f has multiple factors modulo a prime $p > 3$, then $f$ and $f' = 3X^2+1$ have a common factor modulo this prime $p$, and this is the linear factor $f − (X/3)f'$.
Please could you help me to see why this works? And moreover, how far can this be generalized?