Skip to content

Power (loop)

C# while accumulation

Flowchart (ISO 5807)

YesNoStartInput b, er = 1e > 0r = rbe = e − 1Return rEndFigure 1 — P.Pow

Source code

C#
class P {
    static long Pow(int b, int e) {
        long r = 1;
        while (e > 0) {
            r *= b;
            e--;
        }
        return r;
    }
}

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

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

Related examples