Example 5. Given $a_{1}=a, a_{n+1}=p a_{n}+d(p, d$ are constants, $p \neq 1, d \neq 0$ ). Try to find the general term $a_{n}$.
Solution: Given $a_{n+1}=p a_{n}+d$,
we have $a_{n}=p a_{n-1}+d_{\text {n }}$
From (1)-(2), we get $a_{n+1}-a_{n}=p\left(a_{n}-a_{n-1}\right)$.
Let $a_{n+1}-a_{n}=b_{n}$, then $b_{n}=p b_{n-1}$. (From the recursive formula $a_{n}-a_{n-1}=b_{n-1}$ )
Since $b_{n}$ is a difference sequence, and $b_{1}=a_{2}-a_{1}$, it is a geometric sequence with a common ratio of $p$,
$$
\begin{aligned}
\therefore a_{n} & =a+\sum_{k=1}^{n-1} b_{k}=a+\frac{b_{1}\left(p^{n-1}-1\right)}{p-1} \\
& =\frac{\left(a_{2}-a_{1}\right)\left(p^{n-1}-1\right)}{p-1} \cdot(n \geqslant 2)
\end{aligned}
$$

When $n=1$, $a_{n}=a$.
Therefore, $a_{n}=a+\frac{\left(a_{2}-a_{1}\right)\left(p^{n-1}-1\right)}{p-1} \cdot(n \geqslant 1)$