Back In the print window choose "Save as PDF" as the destination
NOTE.CS

Power (x^n)

1 topic · 28 Nov 2026
1

Power (x^n)

Problem Solving
Problem: Calculate x raised to the power n.
Solution 1: Loop O(n) · C++
int x = 2, n = 5;
long long result = 1;
for(int i = 0; i < n; i++){
    result = result * x;
}
cout << result;   // 32
// STL: cout << pow(2, 5);