7. A computer outputs a number 1 or -1 with equal probability every second. Then the probability $p_{n}$ that the sum of the first $n$ numbers output is divisible by 3 is $\qquad$ .
7. $\frac{1}{3}\left(1+2\left(-\frac{1}{2}\right)^{n}\right)$.

These $n$ numbers have a total of $2^{n}$ possible cases. Let the number of cases where the sum of the numbers is divisible by 3 be $x_{n}$. Then the number of cases where the sum is not divisible by 3 is $2^{n}-x_{n}$. For the case of $n+1$ numbers, if their sum is divisible by 3, then the sum of the first $n$ numbers is not divisible by 3; conversely, for each case where the sum of the first $n$ numbers is not divisible by 3, there is a unique $(n+1)$-th number that can make the sum of the first $n+1$ numbers divisible by 3. Therefore,
$$
x_{n+1}=2^{n}-x_{n} \text {. }
$$

This indicates that the probability $p_{n}=\frac{x_{n}}{2^{n}}$ satisfies the recurrence relation
$$
\begin{array}{l}
p_{n+1}=\frac{1}{2}\left(1-p_{n}\right) . \\
\text { Hence } p_{n}=\frac{1}{3}\left(1+2\left(-\frac{1}{2}\right)^{n}\right) .
\end{array}
$$