Notes on exercises from 1.12

For Exercise 1.12.3, digitCount, the easiest way to do this using what we already know is to have 10 base cases, one for each single-digit whole number.

For Exercise 1.12.5, exp, the function should work for all whole number exponents (positive integers and 0).

Exercise 1.12.8 asks you to write a function that computes the Fibonacci sequence, but doesn't specify a name. Call it fib. Also, index the numbers in the sequence starting from 0. That is, the 0th Fibonacci number is 0, the 1st is 1, the 2nd is also 1, the 3rd is 2, etc.


Thomas VanDrunen
Last modified: Mon Jan 27 09:35:46 CST 2020