Assuming[n is an integer, Integrate[(2/Pi) x (Pi - x) Cos[n x], {x, 0, Pi}]]