Initially on the computer screen - some prime number. Every second, the number on the screen is replaced by the number obtained from the previous one by adding its last digit, increased by 1. What is the maximum time it will take for a composite number to appear on the screen?

#
Let the initial number on the screen be 2, then we get the following sequence: $2-5-11-13-17-25$. The sixth number is composite, so in this case, it will take 5 seconds. We will prove that in other cases, it will take no more than 5 seconds.

Indeed, if the number on the screen was an odd prime number not ending in 9, then its last digit will change in a cycle:

$1-3-7-5-1$. This means that no later than 4 seconds, a number ending in 5 will appear. Since it is not equal to 5, it is composite.

If the number on the screen was a prime number ending in 9, then 10 will be added every second. Since 10 gives a remainder of 1 when divided by 3, adding 10 once or twice will definitely result in a number divisible by 3. In this case, it will take no more than 2 seconds for a composite number to appear on the screen.

## Answer

In 5 seconds