Walmart interview question

Repeated Factorial calculation optimisation