Problem Let $f:I\rightarrow \mathbb{R}$ be differentiable in an arbitrary interval I. If $f'(x)=0 $ for all $x\in I$, then $f$ is constant.
My idea If $x \in \operatorname{int}(I)$, we know that $\exists$ $n_0\ge0$ such that $x\in [x-\frac{1}{n_0},x+\frac{1}{n_0}]$ then by the Intermediate Value Theorem, there exists a $c$ in this interval satisfying $$f'(c)=\frac{f(x+\frac{1}{n_0})-f(x-\frac{1}{n})}{n_0}.$$
But we know $f'(c)=0$ by hypothesis, so $f(x+\frac{1}{n_0})=f(x-\frac{1}{n_0})$ and its true for all $n\ge n_0$, then by continuity of $f$ we have that $f$ is constant on $[x-\frac{1}{n_0},x+\frac{1}{n_0}]$.
Since we don't know if $I$ is a closed interval, we can use $\operatorname{Cl}(I)=[a,b]$ because it is closed and also connected. So I can make a partition $$P: a<x_1<\dotsb<x_n<b$$ with $x_i \in I$ for all $i$.
Thus, $f$ is constant on $\operatorname{int}(I)$ and by continuity of $f$, if $I$ is closed we have that $f$ has the same value on $a$ and $b$.
Question
Is that approach enough to prove the statement?
Is there an easier way to show that?