7. (1976 Polish Mathematical Olympiad) A fishing boat is fishing in the territorial waters of a foreign country without permission, and each time it casts a net, it causes a loss of equal value to the country's fishing yield. The probability that the boat is detained by the foreign coast guard during each net casting is $1 / k$, where $k$ is a natural number of the country. Assume that the events of the boat being detained or not during each net casting are independent of the previous fishing process. If the fishing boat is detained by the foreign coast guard, all the fish caught are confiscated, and it cannot fish in the future. The captain plans to leave the foreign territorial waters after casting the net for the $n$th time. Because the possibility of the fishing boat being detained by the foreign coast guard cannot be ruled out, the fishing income is a random variable. Find the number $n$ that maximizes the expected value of the fishing income.
7. The probability that a fishing boat is not detained during the first cast of the net is $1-\frac{1}{k}$. Since the events of being detained or not during each cast are independent, the probability of not being detained after $n$ casts is $\left(1-\frac{1}{k}\right)^{n}$. Therefore, the expected value of the catch after $n$ casts is
$$
f(n)=w n\left(1-\frac{1}{k}\right)^{n},
$$

where $w$ is the catch from one cast.
The problem is to determine the natural number $n$ that maximizes $f(n)$.
From the expression (1) of $f(n)$, we know
$$
\begin{aligned}
f(n+1) & =w(n+1)\left(1-\frac{1}{k}\right)^{n+1}=w n\left(1-\frac{1}{k}\right)^{n} \cdot\left(1-\frac{1}{k}\right)\left(\frac{n+1}{n}\right) \\
& =f(n)\left(1-\frac{1}{k}\right)\left(1+\frac{1}{n}\right)=f(n)\left[1+\frac{(k-1)-n}{k n}\right] .
\end{aligned}
$$

Since $1+\frac{(k-1)-n}{k n} \geqslant 1$ is equivalent to $k-1-n \geqslant 0$ or $n \leqslant k-1$, therefore
$$
\begin{array}{l}
f(n+1)>f(n), \text { when } n=1,2, \cdots, k-2 \text {; } \\
f(n+1)=f(n), \text { when } n=k-1 \text {; } \\
f(n+1)<f(n), \text { when } n=k, k+1, \cdots \text {; }
\end{array}
$$

Therefore, $f$ reaches its maximum value when $n=k-1$.