Skip to content

Taylor series for e^x

C# series accumulation

Flowchart (ISO 5807)

StartInput x, nterm = 1sum = 1i = 1, n − 1, 1term = term·x / isum = sum + termReturn sumEndFigure 1 — Program.Exp

Source code

C#
class Program {
    static double Exp(double x, int n) {
        double term = 1;
        double sum = 1;
        for (int i = 1; i < n; i++) {
            term = term * x / i;
            sum = sum + term;
        }
        return sum;
    }
}

The editor opens with this code — change it and the chart redraws.

Language
C#
Constructs
series accumulation
Topic
Algorithms
Formats
Word, Visio, draw.io, PDF, SVG

Related examples