Last time | Next time |
You can do this one by induction, but you were told to do it directly from the definition of the Fibonacci numbers (i.e. by the recurrence relation).
But the point of this exercise was to define the sum recursively, so we need a base case and an inductive step: \[ \left\{ \begin{array}{cc} {n=1}&{gp(1)=a}\cr {n > 1}&{gp(n)=gp(n-1)+ a r^{n-1}} \end{array} \right. \]
If you follow the code, it's very similar to the definition of the geometric progression.
The upshot was that we can adapt the closed-form solution for the first-order, linear, constant coefficient, non-homogeneous equation, which is appropriate for problems like the Tower of Hanoi with \[ \left\{ \begin{array}{cc} {n=1}&{C(1)=1}\cr {n > 1}&{C(n)=2C(n-1)+ 1} \end{array} \right. \] to handle "divide and conquer" problems like binary search.