Let $a_n$ be a non-negative real numbers and define \begin{align} f(x) = \sum_{n=1}^{\infty} a_n \operatorname{max}\{1-|x-2n|,0\}, \quad x \in [0,\infty). \end{align} I want to find the necessary and sufficient condition on the sequence $(a_n)$ for the series to converge uniformly on $[0, \infty)$.
For $x\geq 2n+1$, $f(x) =0$, so I can restrict the range of $f(x)$ to $[0,2n+1]$, but this seems weired since we are dealing with whole summation. I also think about one direction via Weistrass M-test or both direction with Cauchy, $|s_n - s| < \epsilon$ for $s_n = \sum_{k=1}^n a_k \max\{1-|x-2k|,0\}$ but cannot finish writing solution
Hint: Look at the disjoint intervals $(2n-1,2n+1)$. Observe that only one term in this series is non-zero in this interval. Use this to conclude that $\sum\limits_{k=n}^{m}a_k \max \{1-|x-2k|,0\} \leq \max \{a_n, a_{n+1},....,a_m\}$ for all $x$ whenever $n <m$. It follows that the series converges uniformly if $a_n \to 0$. Converse follows from the fact that if the series converges uniformly then $a_n \max \{1-|x-2n|,0\} \to 0$ uniformly so (putting $x=2n$ we see that) $a_n$ must tend to $0$.