4. Find all pairs of natural numbers $(a, b)$ such that $a^{2}$ is divisible by $b$, $b^{2}$ is divisible by $a$, and $(b+1)^{2}$ is divisible by $a+1$.
Solution. Let $d$ be the greatest common divisor of the numbers $a$ and $b$. Suppose $a = a_1 d$ and $b = b_1 d$. Then, by the condition, $b_1^2 d^2$ is divisible by $a_1 d$, from which (since $a_1$ and $b_1$ are coprime) it is clear that $d$ is divisible by $a_1$. Similarly, $d$ is divisible by $b_1$, and thus $d = a_1 b_1 k$ (we again use the coprimality of the numbers $a_1$ and $b_1$). Then $a = a_1^2 b_1 k$ and $b = b_1^2 a_1 k$. Substituting these equalities into the last condition, we get that $b_1^4 a_1^2 k^2 + 2 b_1^2 a_1 k + 1$ is divisible by $a_1^2 b_1 k + 1$. Subtract the second number from the first and simplify by $b_1 k$. Then we get that $b_1^3 a_1^2 k + 2 a_1 b_1 - a_1^2$ is divisible by $a_1^2 b_1 k + 1$. Now replace $a_1^2 b_1 k$ with -1 in the first term of the expression $b_1^3 a_1^2 k + 2 a_1 b_1 - a_1^2$ and we get that $-(a_1 - b_1)^2$ is divisible by $a_1^2 b_1 k + 1$. Now discard the minus sign in the dividend (it does not affect divisibility) and consider several cases. First, if $a_1 = b_1$, then clearly $a = b$ and this case works. If $a_1 > b_1$, then we have the inequalities $a_1^2 b_1 k + 1 > a_1^2 \geq (a_1 - b_1)^2$, which contradicts divisibility. Then the only remaining case is $b_1 > a_1$. From the inequality $b_1^2 > (b_1 - a_1)^2 > a_1^2 b_1$, we get that $b_1 > a_1^2$. Modulo $b_1$, the number $(b_1 - a_1)^2$ is congruent to $a_1^2$, which, in turn, is less than $b_1$. If we write $(b_1 - a_1)^2 = t(a_1^2 b_1 k + 1)$ and look at this equation modulo $b_1$, and also remember that $t < b_1$, then we can understand that $t = a_1^2$. From this, we deduce that $b_1 - 2 a_1 = a_1^4 k$. Thus $b_1$ is divisible by $a_1$, from which (again, due to coprimality) it is clear that $a_1 = 1$. Then $b_1 = k + 2$ and we get the series of solutions $a = k(k + 2)$ and $b = k(k + 2)^2$ for all natural $k$.

## Senior League