By substitution,
![a_(n+1) = na_n \\ a_(n+1) = n(n-1) a_(n-1) \\ a_(n+1) = n(n-1)(n-2)a_(n-2) \\ ~~~~~~~~~ \vdots \\ a_(n+1) = n(n-1)(n-2)\cdots(n-k)a_(n-k)](https://img.qammunity.org/2023/formulas/mathematics/high-school/wqvji3kvue4shyuyv8umqcb1gwphql94tn.png)
so that after
steps, we end up with
![a_(n+1) = n(n-1)(n-2)\cdots(n-(n-1)) a_(n-(n-1)) = n! a_1 \\\\ ~~~~ \implies a_(2022) = 2022! a_1](https://img.qammunity.org/2023/formulas/mathematics/high-school/4txi8ahn544iayhmwlehm7pk9f41vzwi61.png)
A trailing zero in 2022! comes from factor of 10 = 2×5. The prime factorization of 2022! has a lot more 2s than 5s, so we only need to count how many 5s occur in the factorization. Note that
2022 = 5×404 + 2 ⇒ 404 multiples of 5
2022 = 5²×80 + 22 ⇒ 80 multiples of 5²
2022 = 5³×16 + 22 ⇒ 16 multiples of 5³
2022 = 5⁴×3 + 147 ⇒ 3 multiples of 5⁴
and 5⁵ = 3125 > 2022. So there is total of
404 + 80 + 16 + 3 = 503
distinct factors of 5 in 2022!, and thus 503 trailing zeros in 2022!.
Since
, and the highest power of 5 that divides 1000 is 5⁴ = 625, we know that multiplying 2022! by
can introduce up to 4 more pair-able factors of 5.
So the sum of all the possible numbers of zeros in
is
503 + 504 + 505 + 506 + 507 = 2525