Recurrence Relation where n+1th Term is A by nth term + B to the n

Theorem
Let $\left\langle{a_n}\right\rangle$ be the sequence defined by the recurrence relation:


 * $a_n = \begin{cases} 0 & : n = 0 \\ A a_{n - 1} + B^{n - 1} & : n > 0 \end{cases}$

for numbers $A$ and $B$.

Then the closed form for $\left\langle{a_n}\right\rangle$ is given by:


 * $a_n = \begin{cases} \dfrac {A^n - B^n} {A - B} & : A \ne B \\ n A^{n - 1} & : A = B \end{cases}$

Proof
The proof proceeds by induction.

For all $n \in \Z_{\ge 0}$, let $P \left({n}\right)$ be the proposition:
 * $a_n = \begin{cases} \dfrac {A^n - B^n} {A - B} & : A \ne B \\ n A^{n - 1} & : A = B \end{cases}$

$P \left({0}\right)$ is the case:

When $A = B$:

Thus $P \left({0}\right)$ is seen to hold.

Basis for the Induction
$P \left({1}\right)$ is the case:

When $A = B$:

Thus $P \left({1}\right)$ is seen to hold.

This is the basis for the induction.

Induction Hypothesis
Now it needs to be shown that, if $P \left({k}\right)$ is true, where $k \ge 1$, then it logically follows that $P \left({k + 1}\right)$ is true.

This is the induction hypothesis:
 * $a_k = \begin{cases} \dfrac {A^k - B^k} {A - B} & : A \ne B \\ k A^{k - 1} & : A = B \end{cases}$

from which it is to be shown that:
 * $a_{k + 1} = \begin{cases} \dfrac {A^{k + 1} - B^{k + 1} } {A - B} & : A \ne B \\ \left({k + 1}\right) A^k & : A = B \end{cases}$

Induction Step
This is the induction step:

First let $A \ne B$.

When $A = B$ we have for $k > 0$:

So $P \left({k}\right) \implies P \left({k + 1}\right)$ and by the Principle of Mathematical Induction:


 * $a_n = \begin{cases} \dfrac {A^n - B^n} {A - B} & : A \ne B \\ n A^{n - 1} & : A = B \end{cases}$