5. The sequence $\left\{a_{n}\right\}$ satisfies $a_{1}=p, a_{n+1}=a_{n}^{2}+2 a_{n}$. Then the general term $a_{n}=$ $\qquad$ .
$\begin{array}{l}\text { 5. }(p+1)^{2^{n-1}-1}- \\ \because a_{n}=a_{n-1}^{2}+ \\ 2 a_{n-1}, \\ \quad \therefore a_{n}+1 \\ \quad=\left(a_{n-1}+1\right)^{2} \\ \quad=\left(a_{n-2}+1\right)^{2^{2}}=\cdots=\left(a_{1}+1\right)^{2^{n-1}}=(p+1)^{2^{n-1}}, \\ \text { i.e., } a_{n}=(p+1)^{2^{n-1}}-1 .\end{array}$