Find a Continuous Function 
Possible Duplicate:
Universal Chord Theorem 

I am having a problem with this exercise. Could someone help?
Suppose $a \in (0,1)$ is a real number which is not of the form $\frac{1}{n}$ for any natural number n
n. Find a function f which is continuous on $[0, 1]$ and such that $f (0) = f (1)$ but which does not satisfy $f (x) = f (x + a)$ for any x with $x$, $x + a \in [0, 1]$.
I noticed that this condition is satisfied if and only if $f(x) \geq f(0)$
Thank you in advance
 A: Look at $f(x) = \sin(2\pi x)$. For which values of $a$ can you find an $x \in [0,1]$ with $x+a \in [0,1]$ and $f(x) = f(x+a)$? In particular, if you additionally require $a > \frac{1}{2}$, can such an $a$ exist at all?
Once you've answered that you've solved your problem for some values of $a$. Which are those?
A general solution can be found in the answers to Universal Chord Theorem (Link found by the user who asked the question). To quote $$
f(x) = \sin^2\left(\frac{\pi x}{a}\right) - x \ \sin^2\left(\frac{\pi}{a}\right)
$$
is a solution. This works because $f(x) = f(x+a)$ implies $a \sin^2\left(\frac{\pi}{a}\right) = 0$ and thus $a=\frac{1}{n}$ for some $n \in \mathbb{N}$. The answers to the linked questions also prove that $a \neq \frac{1}{n}$ for every $n \in \mathbb{N}$ is a necessary condition for a solution to exist.
A: Hint:
Since $\frac1a\notin\mathbb N$, there is some $n\in\mathbb N_0$ such that $n<\frac1a<n+1$. Let $r= 1-na$. Then $0<r<a$.
Let us try to find a function such that $f(x+a)-f(x)=1$ for all $x$ with $0\le x \le 1-a$. 
Thus we have by induction $f(x)=k+f(t)$ if $x=ka+t$ with $k\in\mathbb N_0$ and $0\le t<a$ .
Then for $f(1)=f(0)$ we need $f(0)=f(1)=f(na+r)=f(r)+n$, i.e. $f(r)=-n$. See if you can build a complete $f$ from this.
