Task 4. Find the smallest natural number $n$ such that $n^{2}$ and $(n+1)^{2}$ contain the digit 7.
Answer: 26.

Solution. There are no squares ending in the digit 7. There are no two-digit squares starting with 7. Therefore, $n \geq 10$. The first square containing 7 is $576=24^{2}$. Since $25^{2}=625,26^{2}=676,27^{2}=729$, the answer is $n=26$.

Problem 4a. Find the smallest natural number $n$ such that $n^{2}$ and $(n+1)^{2}$ contain the digit 7, but $(n+2)^{2}$ does not.

Answer: 27.

Solution. There are no squares ending in the digit 7. There are no two-digit squares starting with 7. Therefore, $n \geq 10$. The first square containing 7 is $576=24^{2}$. Since $25^{2}=625,26^{2}=676,27^{2}=729,28^{2}=784,29^{2}=841$, the answer is $n=27$.