n=40
We are looking for a number ending with 31 zeros, it can be formed from 5 and even numbers and 10's. Let's try numbers to understand how many zeros we can get:
If n=5
n! will have - 1 zero, (n+1)!- 1 zero, (2n+1)!- 2 zeros, in total 4 zeros,
if n=10, then similarly 2+2+4=8 zeros,
If n=15, then 3+3+6=12,
...
if n=35, then 7+7+14=28 zeros
if n=40, then 8+8+16=32 zeros, resulting number as per given formula will end with 31 digits of 9's
For any n between 35 and 40, resulting number will have less than 30 digits of 9's.