Trigonometric series approximation of a square wave

This applet plots a square wave function with period one along with an approximating trigonometric series. If n terms are requested, the approximating series is

.