27 If the sum of all positive divisors of a positive integer is twice the number itself, then the number is called a perfect number. Find all positive integers $n$ such that $n-1$ and $\frac{n(n+1)}{2}$ are both perfect numbers.
Here we need to use one of Euler's conclusions:
$n$ is an even perfect number $\Leftrightarrow$ there exists a prime $p$, such that $2^{p}-1$ is a prime, and $n=$ $2^{p-1}\left(2^{p}-1\right)$.
We will use this to solve the problem.
Case one: $n$ is odd, then $n-1$ is an even perfect number, so we can write $n-1=$ $2^{p-1}\left(2^{p}-1\right)$, where $p$ and $2^{p}-1$ are both primes, at this time
$$
\begin{aligned}
\frac{n(n+1)}{2} & =\frac{1}{2}\left(2^{p-1}\left(2^{p}-1\right)+1\right)\left(2^{p-1}\left(2^{p}-1\right)+2\right) \\
& =\left(2^{p-1}\left(2^{p}-1\right)+1\right)\left(2^{p-2}\left(2^{p}-1\right)+1\right) .
\end{aligned}
$$

When $p=2$, $n=7, \frac{n(n+1)}{2}=28$, at this moment $n-1$ and $\frac{n(n+1)}{2}$ are both perfect numbers.
When $p \geqslant 3$, let $N=\frac{n(n+1)}{2}$, then $N$ is odd, and
$$
\frac{n+1}{2}=4^{p-1}-2^{p-2}+1=(3+1)^{p-1}-(3-1)^{p-2}+1,
$$

By the binomial theorem, we know $\equiv 3 \times(p-1)-(p-2) \times 3+1+1+1 \equiv$ $6(\bmod 9)$.

Thus $3 \mid N$, but $3^{2} \nmid N$, we can set $N=3 k, 3 \nmid k$, at this time, $\sigma(N)=\sigma(3)$, $\sigma(k)=4 \sigma(k)$, but $2 N \equiv 2(\bmod 4)$, so $\sigma(N) \neq 2 N$, thus $\frac{n(n+1)}{2}$ is not a perfect number.

Case two: $n$ is even, if $4 \mid n$, then $n-1 \equiv-1(\bmod 4) \Rightarrow n-1$ is not a perfect square, at this time for any $d \mid n-1$, by $d \times \frac{n-1}{d}=n-1 \equiv$ $-1(\bmod 4)$, we know that one of $d$ and $\frac{n-1}{d}$ is $\bmod 4$ remainder -1, and the other is $\bmod 4$ remainder 1, leading to $d+\frac{n-1}{d} \equiv 0(\bmod 4)$, thus $4 \mid \sigma(n-1)$, but $2(n-1) \equiv$ $2(\bmod 4)$, so $n-1$ is not a perfect number.
Therefore, $4 \nmid n$, thus we can set $n=4 k+2$, at this time $N=\frac{n(n+1)}{2}=$ $(2 k+1)(4 k+3)$ is odd. Since $(2 k+1,4 k+3)=1$, hence $\sigma(N)=$ $\sigma(2 k+1) \sigma(4 k+3)$.
As above, we know $4 \mid \sigma(4 k+3)$, so if $\sigma(N)=2 N$, then $4|2 N \Rightarrow 2| N$, which is a contradiction.
In summary, the only $n$ that satisfies the condition is $n=7$.