Solution (source code)

= Solution

Apart from its endpoint convention, the ramp is odd, so its constant and <cosine> <Fourier coefficients> vanish. For the <sine> coefficient, evenness of the integrand and <integration by parts> give
$$
b_n=\frac{4K}{L^2}\int_0^{L/2}x\sin\frac{2\pi nx}{L}\,dx
=\frac{4K}{L^2}\left[-\frac{xL}{2\pi n}\cos\frac{2\pi nx}{L}
+\frac{L^2}{4\pi^2n^2}\sin\frac{2\pi nx}{L}\right]_0^{L/2}.
$$
Hence
$$
\boxed{a_0=a_n=0,\qquad b_n=\frac{K(-1)^{n+1}}{\pi n}}.
$$
This is the <Fourier series of a periodic sawtooth>. At the periodic jump, the series sums to zero rather than the assigned endpoint value $K/2$; changing a value at one endpoint does not change the coefficients.