Fourier series for functions on $[-\pi,\pi]$, or, equivalently, $[0,2\pi]$, can be either $f(x)=a_0+\sum_{n=1,2,\ldots} (a_n\cos nx+b_n\sin nx)$ or the complex form $f(x)=\sum_{n\in {\bf Z}} c_n\,e^{inx}$. Either way, among other properties, the integral of $f$ against something else on $[0,2\pi]$ should be the same as the integral of the Fourier series against that same thing, and this device determines all the Fourier coefficients, by integrating against (constants and) sines and cosines or exponentials. Integrating against the constant function $1$ will pick out $a_0$, since constants integrate to $0$ against non-trivial sines and cosines or exponentials: $\int_0^{2\pi} f(x)\,1\,dx=\int_0^{2\pi} a_o\,1\,dx=2\pi\cdot a_o$. Thus, $a_o={1\over 2\pi}\int_0^{2\pi} f(x)\,dx$.
The $2$s and $\pi$s and other constants frequently get misplaced in discussions of Fourier series, so eternal vigilance is required. Double-checking as above is not hard, luckily.