Solution (source code)

= Solution

Suppose $\phi^3=\operatorname{Id}_X$. Since $\phi$ has no fixed points, neither does $\phi^2$: if $\phi^2(x)=x$, then applying $\phi$ gives $\phi(x)=\phi^3(x)=x$. The Lefschetz theorem therefore gives
$$
L(\phi)=L(\phi^2)=0,
\qquad
L(\operatorname{Id}_X)=\chi(X)=n.
$$

For each $q$, the averaging operator
$$
P_q=\frac13\left(I+\phi_*+\phi_*^2\right)
$$
is the projection of $H_q(X;\mathbb Q)$ onto its $\langle\phi\rangle$-invariant subspace, so its trace is an integer. Taking the alternating sum of these traces gives
$$
\sum_q(-1)^q\operatorname{tr}P_q
=\frac13\{L(\operatorname{Id}_X)+L(\phi)+L(\phi^2)\}
=\frac n3.
$$
The left side is an integer. By <Euler-characteristic divisibility from a fixed-point-free cyclic action>,
$$
\boxed{3\mid n.}
$$