A function is a named computational unit: it accepts parameters, performs operations, and may return a result. Naming a calculation lets a larger program reuse it as a small building block. section 7.0 section 7.3
A power function
A power function accepts two inputs, x and y, and calculates xᵞ. It handles the base case y = 0 by returning 1; otherwise, it calculates x multiplied by xᵞ⁻¹. Reapplying the function reduces 2⁵ to 2 × 2⁴, then to 2 × 2 × 2³, until the result is 32. section 7.5
Functions can organize an algorithm by separating its jobs:
- Define parameters that receive the inputs needed for the calculation. section 4.2
- Perform operations and use conditions to choose a path. section 7.3
- Return information to the calling function, such as true or false, instead of printing it directly. section 4.2



















