Does a periodic function have to be bounded?

Nope: $f(x) = 1/(1-x)$ for $x \in [0,1)$. Now extend periodically $f(x + n) = f(x)$ for integers $n$.


If you take the function $$f(x) = \left\{ \begin{array}{ll} \cot(x) & x \neq k \pi, k \text{ integer}\\0 & \text{otherwise}\end{array}\right.$$ This function is defined for all $x \in \mathbb{R}$ and is periodic with period $\pi$. This function is not bounded.

Of course, if you require $f$ to be continuous, then if the function has (WLOG) period 1, it is bounded on $[0,1]$ because it is continuous. It follows that $f$ is bounded on all of $\mathbb{R}$ since it is periodic.


Just to add another example that has period $1$ and is unbounded on every open interval: $$f(x)=\begin{cases}\min\{\,n\in\mathbb N:nx\in\mathbb Z\,\}&\text{if $x\in\mathbb Q$}\\0&\text{otherwise}\end{cases} $$


Take the function $g:[0,1)\to\mathbb{R}^+$ whose value is $1$ on the irrational numbers and $q$ for any rational number of the form $\frac{p}{q}$ with $\gcd(p,q)=1$, then define $f(x)$ as $g(\{x\})$. Since $g$ is unbounded, $f$ is unbounded, too.