5. $a-n$.

For any positive integer $n$, it is known by recursion that $a_{n}>0$.
By $a_{n}-a_{n+1}=\frac{a_{n}}{a_{n}+1}=1-\frac{1}{1+a_{n}} \in(0,1)$, we know the sequence $\left\{a_{n}\right\}$ is decreasing, and for any $n \in \mathbf{Z}_{+}$,
$a_{n}=a_{0}+\sum_{i=1}^{n}\left(a_{i}-a_{i-1}\right)>a-n$.
Thus, $a_{n-1}>a-(n-1)(n \geqslant 2)$.
Therefore, when $n=1$,
$$
\sum_{i=1}^{n} \frac{1}{1+a_{i-1}}=\frac{1}{1+a_{0}}<1 \text {. }
$$

When $2 \leqslant n \leqslant \frac{a}{2}+1$, by the sequence $\left\{a_{n}\right\}$ being decreasing, we get
$$
\sum_{i=1}^{n} \frac{1}{1+a_{i-1}}<\frac{n}{1+a_{n-1}}<\frac{n}{a-n+2} \leqslant 1 .
$$

Hence, $a-n<a_{n}=a-n+\sum_{i=1}^{n} \frac{1}{1+a_{i-1}}<a-n+1$.
Therefore, the greatest integer not exceeding $a_{n}$ is $a-n$. In particular, when $n=0$, it also holds.
5. In the sequence $\left\{a_{n}\right\}$,
$$
a_{0}=a\left(a \in \mathbf{Z}_{+}\right), a_{n+1}=\frac{a_{n}^{2}}{a_{n}+1} .
$$

When $0 \leqslant n \leqslant \frac{a}{2}+1$, the greatest integer not exceeding $a_{n}$ is $\qquad$