One thing often not touched upon in Fourier analysis is that the set of functions
$\{f: [-\pi,\pi] \to \Bbb R\}$ that are integrable form a vector space:
We can add them:
$(f+g)(x) = f(x) + g(x)$
And multiply them by a real number:
$(cf)(x) = c \cdot f(x)$
Furthermore, the definite integral:
[math]\int_{-\pi}^{\pi}f(x)g(x)\ dx[/math]
satisfies all the requirements of an inner product.
Now, it is a difficult theorem to show that:
$\{1,\cos(x),\sin(x),\cos(2x),\sin(2x),\dots,\cos(nx),\sin(nx),\dots\}$
forms a basis for this vector space, but it is somewhat easier to show it is a basis for the subset of such functions that have a Fourier series, and it turns out that this basis (sometimes the scalar multiple of 1 is modified for cleaner formulas) is orthogonal with respect to this inner product. This means that the "coordinates" of these vectors (functions) are the projections of the functions onto their orthogonal basis vectors, and that is precisely what the Fourier coefficients ARE
(just like with "normal vectors" the $j$-th coordinate of:
$v = (v_1,\dots,v_n)$ is $v\cdot e_j = v_j$, where $e_j = (0,\dots,1,\dots,0)$ with all 0's except for a 1 in the $j$-th place).
As such, from the uniqueness of the linear combination of basis elements for any vector, we have that the Fourier series of $\cos(nx)$ is $\cos(nx)$ and similarly the Fourier series of $\sin(nx)$ is also $\sin(nx)$, with no actual need to compute the Fourier coefficients.
A neat trick:
Evaluate the Fourier series for $x^2$ on $[-\pi,\pi]$ at $x = \pi$ to conclude that:
$\zeta(2) = \dfrac{\pi^2}{6}$
(the zeta function is defined by: [math]\zeta(s) = \sum_{n = 1}^{\infty} \frac{1}{n^s}[/math] for any complex number $s$ with real part > 1).