(a) Fix a positive integer $M$ and let $\{f_{n} : [0, M]\rightarrow \mathbb{R}\}$ be a sequence of functions. Suppose that $f_{n}\rightarrow f$ pointwise on $[0, M]$ and that $f_{n}\rightarrow f$ uniformly on each subinterval $[k-1, k]$ for each $k=1, \ldots, M$. Prove that $f_{n}\rightarrow f$ uniformly on $[0, M].$
(b) Now let $\{g_{n}:[0, \infty)\rightarrow \mathbb{R}\}$ be a sequence of functions that converges pointwise to $g$ : $[0, \infty)\rightarrow \mathbb{R}$. Suppose also that $g_{n}\rightarrow g$ uniformly on $[k-1, k]$ for each positive integer $k$. Give an example to show that $g_{n}$ does not necessarily converge uniformly to $g$ on all of $[0, \infty)$.
for part (a), i know that definition for pointwise convergence is:
$\forall\epsilon>0$ and $\forall x\in[0,M],$ $\exists N(\epsilon,x)$ s.t. $\left|f_{n}(x)-f(x)\right|<\epsilon, \forall n\geq N$
Definition for uniform convergence on each subinterval $[k-1,k]$ is:
$\forall\epsilon>0,\exists N_{k}(\epsilon)$ s.t. $\left|f_{n}(x)-f(x)\right|<\epsilon, \forall x\in\left[k-1,k\right]$ & $n\geq N_{k}(\epsilon)$
Thus, I need to show uniform convergence on $[0,M]$:
$\forall\epsilon>0,\exists N(\epsilon)$ s.t. $\left|f_{n}(x)-f(x)\right|<\epsilon, \forall x\in\left[0,M\right]$ & $n\geq N(\epsilon$
I know that i should taking some max value of $N$ but sure not how to
I think i will be able to do part (b) if I can understand part (a)