Given a sequence $ \{a_n\}_{n=1}^{\infty} $, such that the series $ \sum_{n=1}^{\infty} a_n $ converges absolutely, show that the series $$ \sum_{n=1}^{\infty} a_n \cos(nx) $$ converges for all $ x \in \mathbb{R} $. Additionally, if the sum is a function $ f(x) $, prove that $ f(x) $ is continuous, and that its Fourier series is $$ \sum_{n=1}^{\infty} a_n \cos(nx). $$
For the first part, I used the M-test, since $ |\cos(nx)| \leq 1 $ and the fact that the series $ \sum_{n=1}^{\infty} a_n $ is absolutely convergent. It follows that the series $ \sum_{n=1}^{\infty} a_n \cos(nx) $ is uniformly convergent to some function $ f(x) $. The function $ f(x) $ is continuous because of the uniform convergence of the series and the fact that $ a_n \cos(nx) $ is continuous for all $ n $.
I am not sure about the last part: how do I show that the Fourier series of $ f(x) $ is the series $ \sum_{n=1}^{\infty} a_n \cos(nx) $?
Edit: Thanks to Srini for the comment, I substituted f(x) with $$\sum_{n=1}^\infty a_n \cos(n x)$$, when calculating the Fourier coefficients and it worked out.