| 5 | double power(double x, int n); |
| 6 | |
| 7 | int main() |
| 8 | { |
| 9 | for (int i{ -3 }; i <= 3; ++i) // Calculate powers of 8 from -3 to +3 |
| 10 | std::cout << std::format("{:10g}", power(8.0, i)); |
| 11 | |
| 12 | std::cout << std::endl; |
| 13 | } |
| 14 | |
| 15 | // Recursive function to calculate x to the power n |
| 16 | double power(double x, int n) |