2. Find the greatest three-digit number $n$, for which the sum

$$
1^{2}+2^{3}+3^{4}+4^{5}+\ldots+n^{n+1}
$$

is divisible by three.
2. First, we notice that when dividing by three, the numbers $k$ and $k^{3}$ always give the same remainder (it is sufficient to verify this for $k \in \{0,1,2\}$). This means that all numbers $k, k^{3}, k^{5}, k^{7}, \ldots$ give the same remainder, which depends only on the remainder when the number $k$ is divided by three. For any natural number $n$, the numbers

$$
(n+6)^{n+7}, n^{n+7}, n^{n+1}
$$

give the same remainder when divided by three. This means that the remainders of the individual terms in the sum

$$
S(n)=1^{2}+2^{3}+3^{4}+4^{5}+\ldots+n^{n+1},
$$

repeat with a period of 6 (the first six are $1,2,0,1,1,0$). Since $999=6 \cdot 166+3$, it is clear that $S(999)$ gives the same remainder when divided by three as $166 \cdot (1+2+0+1+1+0)+1+2+0=833$, which is 2. From the given calculation, we can see that $S(998)$ also gives a remainder of 2, while $S(997)$ is divisible by three, so the sought number is 997.

Another solution. Starting from the same observation, we notice that

$$
S(n+18) \equiv S(n+12)+S(6) \equiv S(n+6)+2 S(6) \equiv S(n)+3 S(6) \equiv S(n) \pmod{3}
$$

so the remainders of the numbers $S(n)$ repeat with a period of 18. By calculation, we find that the remainders of the numbers $S(1), S(2), S(3), S(4), \ldots$ form the sequence (one period is marked with parentheses)

$$
\underbrace{1,0,0,1,2,2,0,2,2,0,1,1,2,1,1,2,0,0,} 1,0,0,1,2,2, \ldots
$$

The sum $S(n)$ is divisible by three if and only if the number $n$ gives one of the remainders $2,3,7,10,17$ or 0 when divided by 18.

Since the largest three-digit number is of the form $999=18 \cdot 55+9$, the sought number is $18 \cdot 55 + 7 = 997$.

Full solution is worth 6 points. For merely revealing the periodicity of the terms, award 3 points.