While surfing the web I got to this site: http://en.wikipedia.org/wiki/Fourier_series “Hey, I why not write something like this in C#!” The rather scary looking formulas did not withhold me to start coding (see below Fig. 1 and Fig. 2) The formula from Fig. 2 is hidden under one of the sawtooth pictures on the site. Here is the code I came up with.
Start a forms application, drop a panel on the form in the designer and name it PlotPanel.
Fill in or add the code below and enjoy. With the comments it should be clear what is done, otherwise feel free to ask. An example output is also provided. If you want the same effect as on the site, put the method in a loop.
Have fun! :)