Solution:
Suppose Sean instead follows this equivalent procedure: he starts with M=10…0 on the board, as before. Instead of erasing digits, he starts writing a new number on the board. He goes through the digits of M one by one from left to right, and independently copies the nth digit from the left with probability n1. Now, let an be the expected value of Sean's new number after he has gone through the first n digits of M. Note that the answer to this problem will be the expected value of a2021, since M has 2021 digits.
Note that a1=1, since the probability that Sean copies the first digit is 1.
For n>1, note that an is 3an−1 with probability n1, and is an−1 with probability nn−1. Thus,
E[an]=n1E[3an−1]+nn−1E[an−1]=nn+2E[an−1].
Therefore,
E[a2021]=24⋅35⋯20212023=2⋅32022⋅2023=337⋅2023=681751