Let $$f(x) = \begin{cases} \sum_{k=0}^\infty \frac{e^{inx}}{1+k^2} &\mbox{if } x \ne 2\pi k \\ 0 & \mbox{if } x = 2\pi k \end{cases}$$
Find the Fourier coefficients of $f(x)$
What I did:
$$\hat{f}(n) = \frac{1}{2\pi} \int_0^{2\pi} f(x)e^{-inx} \ dx = \frac{1}{2\pi} \int_0^{2\pi} \sum_{k=0}^\infty \frac{e^ikx}{1+k^2} e^{-inx} \ dx = \frac{1}{2\pi} \int_0^{2\pi} \sum_{k=0}^\infty \frac{e^i(k-n)x}{1+k^2} \ dx$$
Now, let's observe the series: $\sum_{k=0}^\infty \frac{e^i(k-n)x}{1+k^2}$
$$\left|\sum_{k=0}^\infty \frac{e^i(k-n)x}{1+k^2}\right| \le \sum_{k=0}^\infty \left|\frac{e^i(k-n)x}{1+k^2}\right| \le \sum_{k=0}^\infty \frac{1}{1+k^2} \lt \infty$$
Therefore, by Weierstrass M-test the series converges uniformly and absolutely. So we may interchange summation and integration:
$$= \frac{1}{2\pi} \sum_{k=0}^\infty \int_0^{2\pi} \frac{e^{i(k-n)x}}{1+k^2} \ dx = \frac{1}{2\pi} \sum_{k=0}^\infty \frac{1}{1+k^2} \int_0^{2\pi} e^{i(k-n)x} \ dx$$
Easy to see that the integral vanishes for every $k\ne n$ and for equals $2\pi$ for $n=k$.
So, all in all, we have that $$\hat{f}(n) = \frac{1}{2\pi}\frac{2\pi}{1+n^2} = \frac{1}{1+n^2}$$
Find the Fourier series of $g(x) = \int_0^x f(t)\ dt$ where $x\in [-\pi,\pi]$
so we know that (assuming my work is correct so far) $f(x) = \sum_{n=-\infty}^\infty \frac{1}{n^2 + 1} e^{int}$
Therefore,
$$g(x) = \int_0^x f(t) \ dt = \int_0^x \sum_{n=-\infty}^\infty \frac{1}{n^2+1} e^{int} \ dt = \sum_{n=-\infty}^\infty \frac{1}{n^2+1} \int_0^x e^{int} \ dt = \sum_{n=-\infty}^\infty \frac{1}{n^2+1} \left( \frac{e^{inx}-1}{in} \right) $$
At this point I got a little stuck..
Request
I'd like to get a review/critique of my work and help with finding the fourier series of $g(x)$. I didn't used the fact that $f(x)$ vanishes for $x=2\pi k$ but I dind't see why it matters.
Note that you perform your integrations on $[0, 2 \pi]$; please check this, usually the formulae that you use are valid on $[- \pi, \pi]$.
You could have solved it in a quicker way. You know that $g(x) = \sum \limits _{k=0} ^\infty \frac 1 {1+k^2} \Bbb e ^{\Bbb i k x}$. On the other hand, $g$ admits a Fourier series so $g(x) = \sum \limits _{k=-\infty} ^\infty a_k \Bbb e ^{\Bbb i k x}$. Comparing these two series, $a_k = 0, \space k<0$ and $a_k = \frac 1 {1+k^2}, \space k \ge 0$. (I'm cheating here a little bit because your function has discontinuities in $2k \pi$, but this does not change the core and the conclusion of my argument.)
For the second part, note that you'll want to introduce an integral inside a series; this can be done safely if the series converges uniformly, otherwise you never know what you get. Fortunately, for every $x$ you have $\sum \limits _{k=0} ^\infty \Big| \frac 1 {1+k^2} \Bbb e ^{\Bbb i k x} \Big| \le \sum \limits _{k=0} ^\infty \frac 1 {1+k^2}$ so, by Weierstass's M-test, the series defining $g$ converges uniformly on $\Bbb R$ and you may interchange integration and summation.
Integrating (please note that the summation starts at $0$, not $-\infty$, and this first term must be integrated separately), one gets $x + \sum \limits _{k=1} ^\infty \frac {\Bbb e ^{\Bbb i k x} -1} {(1 + k^2) \Bbb i k}$. Now, this series is easily seen to converge absolutely, therefore one may rearrange its terms and this will not change its values. Therefore, $\int \limits _0 ^x g(t) \Bbb d t = x - \Bbb i \sum \limits _{k=1} ^\infty \frac {\Bbb e ^{\Bbb i k x}} {(1 + k^2) k} + \Bbb i \sum \limits _{k=1} ^\infty \frac 1 {(1 + k^2) k}$.
Finally, it is easy to compute the Fourier series of $x$; it is $\Bbb i \sum \limits _{k=-\infty} ^\infty \frac {(-1)^k} k \Bbb e ^{\Bbb i k x}$, with the term corresponding to $k=0$ being $0$.
Putting all this together you get
$$\int \limits _0 ^x g(t) \Bbb d t = \Bbb i \sum \limits _{k=1} ^\infty \frac 1 {(1 + k^2) k} + \Bbb i \sum \limits _{k= -\infty} ^{-1} \frac {(-1)^k} k \Bbb e ^{\Bbb i k x} + \Bbb i \sum \limits _{k=1} ^\infty \Big( \frac {(-1)^k} k - \frac 1 {k (1+k^2)} \Big) \Bbb e ^{\Bbb i k x}.$$