## Proving a continuous function on [0, 1] has a "periodic equalty"?

I've, once again, already worked out this problem, and am just looking for somebody to validate my proof, or point out any errors. Heres the problem:

If $f$ is continuous on $[0, 1]$ and $f(0) = f(1)$, then prove there is some natural number number $n$ such that:

$f(x) = f(x + \frac{1}{n})$

for some $x \in [0, 1]$

Now, heres my attempt at proving it:

Let

$g(x) = f(x) - f(x + \frac{1}{n})$

We know that $g$ is continuous on $[0, 1]$. We also know that there exists a number $z \in [0, 1]$ such that:

$f(z) \geq f(x)$

for all $x \in [0, 1]$

Suppose we let $a = z - \frac{1}{n}$; then we know that we can choose an $n$ large enough to ensure that (since $f(z) \geq f(x)$ for all x):

$f(z - \frac{1}{n}) < f(z + \frac{1}{n} - \frac{1}{n})$

Which means that:

$f(a) < f(a + \frac{1}{n})$

Which implies that:

$g(a) < 0$

Now, we can choose a $b \in [0, 1]$ simmilarly. Suppose $b = z$, then we can ensure (by choosing a large enough or small enough $n$) ensure that:

$f(z + \frac{1}{n}) < f(z)$

Equivilantly...

$f(b + \frac{1}{n}) < f(b)$

Which implies that:

$0 < g(b)$

Now, by that one theorem (I don't remeber its name), since:

$g(a) < 0 < g(b)$

and $g$ is continuous on $[0, 1]$, and $a, b \in [0, 1]$, then we a garunteed there exists some $x \in [0, 1]$ such that:

$g(x) = 0$

This implies that we are also garunteed an $x \in [0, 1]$ such that:

$f(x) = f(x + \frac{1}{n})$

This completes the proof,.... I hope

I'm not certain if this proof is correct... I'm alittle unsure about weather or not I can garuntee some of the inequalities involving $f(z)$. I'm not even sure if this proof "goes in the right direction" persay. Any guidence, validation, error-pointing-out, and general advice would be much appreciated. Thanks in advance