|
lab_quacks
Spiteful Stacks and Questionable Queues
|
Namespace to contain the recursion exercise code. More...
Functions | |
| int | sumDigits (int n) |
| Given a non-negative int n, return the sum of its digits recursively (no loops). More... | |
| int | triangle (int rows) |
| Compute the total number of blocks in a triangle of blocks. More... | |
Namespace to contain the recursion exercise code.
| int RecursionExercises::sumDigits | ( | int | n | ) |
Given a non-negative int n, return the sum of its digits recursively (no loops).
Examples:
sumDigits(126) == 9sumDigits(49) == 13sumDigits(12) == 3| n | The number to sum the digits of |
| int RecursionExercises::triangle | ( | int | rows | ) |
Compute the total number of blocks in a triangle of blocks.
In a triangle of blocks, the topmost row has 1 block, the next row down has 2 blocks, the next row has 3 blocks, and so on.
| rows | The number of horizontal rows in the triangle |