I just learned that $a_0$ is basically the average of a function $f(x)$ on the interval $[-\pi, \pi]$, and that a Fourier series is given by $$ f(x) = a_0 + \sum_{n=1}^\infty (a_n \sin(nx) + b_n\cos(nx))$$
where $a_0 = \dfrac{1}{2\pi} \int_{-\pi}^{\pi} f(x) dx $. However, on other sources online I usually see that the $a_0$ is divided by 2. What is the reason for this?
If you look carefully at these other sources you will find that they define $a_0$ differently. If you work out $a_0$ their way and divide by $2$, then work it out your way and don't divide by $2$, you will find that you get the same constant term in the Fourier series.