4. Determine all pairs of positive integers $(a, n)$ with $a \geq n \geq 2$ for which the number $(a+1)^{n}+a-1$ is a power of 2.
Solution: If we develop $(a+1)^{n}+a-1$ using the binomial theorem, we get:

$$
a^{n}+\cdots+\frac{n(n-1)}{2} a^{2}+n a+1+a-1=a^{n}+\cdots+\frac{n(n-1)}{2} a^{2}+(n+1) a .
$$

Since all terms are divisible by $a$, and since $(a+1)^{n}+a-1$ is a power of 2, $a$ must also be a power of 2. Let $a=2^{b}$ and $(a+1)^{n}+a-1=2^{c}$. From the condition $a \geq 2$, we get $b \geq 1$. Furthermore, from the condition $n \geq 2$, we also get $2^{c}>a^{2}=2^{2 b}$, and thus $c>2 b$.

We observe that all terms in $(\star)$, except possibly the last one, are divisible by $a^{2}=2^{2 b}$.

Since $c>2 b, 2^{c}$ is divisible by $2^{2 b}$, and therefore, by difference, $(n+1) a$ is also divisible by $2^{2 b}$. Since $a=2^{b}$, it follows that $2^{b}$ divides $n+1$, i.e., $n+1=2^{b} \cdot m=a m$ for some positive integer $m$. From the condition $a \geq n \geq 2$, the only possible value for $m$ is $m=1$, and thus $n=a-1=2^{b}-1$. In particular, $b$ cannot be 1, otherwise $n=1$, and thus $b>1$, from which $a \geq 4$ and $n=a-1 \geq 3$. From the last inequality, it follows that $2^{c}>a^{3}$, and thus $c>3 b$.

Rewriting $(a+1)^{n}+a-1$ using the collected information:

$$
\begin{aligned}
(a+1)^{n}+a-1 & =a^{n}+\cdots+\frac{n(n-1)(n-2)}{6} a^{3}+\frac{n(n-1)}{2} a^{2}+(n+1) a= \\
& =2^{n b}+\cdots+\frac{\left(2^{b}-1\right)\left(2^{b}-2\right)\left(2^{b}-3\right)}{6} 2^{3 b}+\frac{\left(2^{b}-1\right)\left(2^{b}-2\right)}{2} 2^{2 b}+2^{2 b}
\end{aligned}
$$

All terms, except possibly the last two, are divisible by $2^{3 b}$; moreover, $2^{c}$ is also divisible by $2^{3 b}$, and thus $\frac{\left(2^{b}-1\right)\left(2^{b}-2\right)}{2} 2^{2 b}+2^{2 b}=\left(2^{b}-1\right)\left(2^{b-1}-1\right) 2^{2 b}+2^{2 b}$ is also divisible by $2^{3 b}$.

It follows that $\left(2^{b}-1\right)\left(2^{b-1}-1\right)+1=2^{2 b-1}-2^{b}-2^{b-1}+2$ is divisible by $2^{b}$, but this is only possible when $b=2$: if $b>2$, in fact, all terms of the expression except the last one are divisible by 4, and thus the sum is not divisible by 4 (and therefore not by $2^{b}$).

The only remaining case is $b=2$, from which $a=4$ and $n=3$. In this case, a simple check shows that $(a+1)^{n}+a-1=128=2^{7}$, so this is a solution.

In conclusion, there is a unique solution: $a=4, n=3$.