i am learning fourier series and i am stuck on an integral. 

So i am looking for $$a\_n={1\over\pi}\int\_0^{2\pi} f(x)\cos(nx)\ dx ={1\over\pi}\int\_0^{2\pi} \frac{( \pi-x)^2}{4}\cos(nx)\ dx$$

$$={1\over4\pi}\int\_0^{2\pi} ( \pi-x)^2\cos(nx)\ dx$$

I know that the answer is $ \frac{1}{n^2}$ but would really like someone to show me and explain a simple way of working this out as i am going to have exam questions like this and so assuming there must be a simple way of working this out..

Many thanks