MCPcopy Create free account
hub / github.com/Apress/beginning-cpp20 / localHelper

Function localHelper

Examples/NoModules/Appendix A/ExA_09/Power.cpp:4–9  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2namespace
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
12double power(double x, int n) // power() has external linkage

Callers 1

powerFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected