← All examples

Power (loop)

C# Algorithms

while accumulation

Flowchart (ISO 5807)

YesNoStartInput b, er = 1e > 0r *= be--Return rEndFigure 1 — P.Pow

Source code

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