Show that if f is continuous and periodic then f attains both its minimum and its maximum. Show that if f is continuous and periodic then f attains both its minimum and its maximum.
The solution is given below:



But I wonder why he choose the k like this and is the solution does not contain any flaws? 
I can not understand the general idea of the proof, could anyone explain it for me please?
 A: Consider the picture below:
We first divide the real line into the intervals $[0,T]$, $[T,2T]$,... (negative also but we assume that $C>0$ for this picture). Suppose that $C$ exists such that $f(C)>M = \sup\{f(x):0\leq x \leq T\}.$ 
We pick $k$ such that $C\in [kT,(k+1)T]$. This is possible since these intervals cover $\mathbf{R}$. This is precisely what the author means by letting $k = \lfloor C/T \rfloor $ that is the largest integer $k$ such that $k\leq C/T$ which implies that $k\leq C/T\leq k+1$ and therefore $C\in [kT,(k+1)T].$
Now $kT\leq C\leq (k+1)T\Rightarrow 0\leq C-kT\leq (k+1)T-kT = T$ and therefore this would imply that if we write $C' = C-kT$
$$f(C') = f(C-kT) = f(C) >M$$
However $C'\in [0,T]$ by the above inequality and therefore $f(C')\leq M$ thus we have derived a contradiction.
A: This proof, while correct, is very clumsy, to say the least.
Since $f$ is periodic any value taken by $f$ is already taken in the interval $[0,T]=:J$. The restriction of $f$ to $J$ is continuous, hence $f\restriction J$ takes a maximal value $M$ at some point $\xi\in J$. It follows that $\max_{x\in{\mathbb R}} f(x)=M=f(\xi)$.
