$f : M → M$ be a transitive continuous transformation, if $\phi \circ f=\phi$, then $\phi$ is constant. We say that $f$ is transitive if there exists some $x ∈ M$ such that $ \{ f^n(x) :
n ∈ N \}$ is dense in $M$.
Let $f : M → M$ be a transitive continuous transformation in a compact metric
space, and $\phi:M \rightarrow \mathbb{R}$ continuous. If $\phi \circ f=\phi$, then $\phi$ is constant.
Attempt:I have tried to show that $ \phi (x) = \phi (y)$ for any $y$ in $M$. Using the orbit of $x$ is dense in $M$, I find a sequence $f^{n_s}(x)$ converging to $y$. Then using that $\phi \circ f=\phi$, by recursion we obtain $\phi \circ f^n=\phi$. Then $\lim\limits_{s \to \infty} ( \phi \circ f^{n_s})(x)=\phi(x) $, but by continuity $\phi (\lim\limits_{s \to \infty} f^{n_s}(x))=\phi(x)$ implying $\phi (y)=\phi(x)$. 
I imagine the proof is something of that kind, because the fact of being  $ \{ f^n(x) :n ∈ N \}$ dense, and of equality $\phi \circ f^n=\phi$ says that $ \phi(x)$  coincides with almost every point in $M$. Does anyone have any better suggestions?

Since $\phi\circ f=\phi$, for every integer $n$, $\phi\circ f^n=\phi$. This implies that $\phi(f^n(x))=\phi(x)$, we deduce that the restriction of $\phi$ on $Y=\{f^n(x)\}$ is constant, and $\phi$ is constant on the adherence $\overline{Y}=X$ of $Y$.
