31. Find all positive integers $n$, such that
$$\frac{2^{n}-1}{3} \in \mathbf{N}^{*}$$

and there exists $m \in \mathbf{N}^{*}$, satisfying ${ }^{*}$ :
$$\left.\frac{2^{n}-1}{3} \right\rvert\,\left(4 m^{2}+1\right)$$
31. From $\frac{2^{n}-1}{3} \in \mathbf{N}^{\cdot}$, we know that $n$ is even. If there exists an odd number $q \geqslant 3$ such that $q \mid n$, then using factorization we know that $\left(2^{q}-1\right) \mid\left(2^{n}-1\right)$. Combining $2^{q}-1 \equiv-2(\bmod 3)$, we know that $\left(2^{q}-1\right) \left\lvert\, \frac{2^{n}-1}{3}\right.$, which indicates $\left(2^{q}-1\right) \mid\left(4 m^{2}+1\right)$. However, when $q \geqslant 3$, $2^{q}-1 \equiv-1$ $(\bmod 4)$, so $2^{q}-1$ has a prime factor $p$ satisfying $p \equiv 3(\bmod 4)$. For this $p$, we have $p \mid\left(4 m^{2}+1\right)$, i.e.,
$$(2 m)^{2} \equiv-1(\bmod p)$$

By Euler's criterion, we know that -1 is not a quadratic residue modulo $p$, leading to a contradiction. Therefore, $n$ can only be a power of 2, i.e., there exists $k \in \mathbf{N}^{*}$ such that $n=2^{k}$.

On the other hand, if $n=2^{k}, k \in \mathbf{N}^{*}$, then
$$\frac{2^{n}-1}{3}=\left(2^{2}+1\right)\left(2^{2^{2}}+1\right) \cdot \cdots \cdot\left(2^{2^{k-1}}+1\right)$$

Using the fact that when $r \in \mathbf{N}^{*}$, $\left(2^{2^{r}}-1,2^{2^{r}}+1\right)=1$, and
$$2^{2^{r}}-1=(2+1)\left(2^{2}+1\right) \cdot \cdots \cdot\left(2^{2^{r-1}}+1\right)$$

we know that $2^{2}+1,2^{2^{2}}+1, \cdots, 2^{2^{k-1}}+1$ are pairwise coprime. Therefore, by the Chinese Remainder Theorem, there exists $m \in \mathbf{N}^{*}$ such that for $1 \leqslant i \leqslant k-1$, we have
$$m \equiv 2^{2^{i-1}}-1\left(\bmod 2^{2^{i}}+1\right)$$

Thus, $4 m^{2} \equiv\left(2^{2^{i-1}}\right)^{2}=2^{2^{i}} \equiv-1\left(\bmod 2^{2^{i}}+1\right)$, which implies $\left.\frac{2^{n}-1}{3} \right\rvert\,$ $\left(4 m^{2}+1\right)$.

In summary, $n$ is all numbers of the form a power of 2.