| 2 | namespace |
| 3 | { |
| 4 | double localHelper(double x, unsigned n) // localHelper() has internal linkage |
| 5 | { |
| 6 | if (n == 0) return 1.0; // Recursion base case |
| 7 | const double y{ localHelper(x, n / 2) }; // See Exercise 8-8 for an explanation |
| 8 | return y * y * (n % 2 == 1 ? x : 1.0); |
| 9 | } |
| 10 | } |
| 11 | |
| 12 | double power(double x, int n) // power() has external linkage |