i donot know the logic but was thing of using trailing of zero
In this question we have to use trailing of zeros concept
Refer this
last test case is showing run time error
Increase MAX to 100000 and then check.
error soved but why max is changed to 100000
Because values like 500! will have alot more digits than 500