Gird Technologies interview question

Factorial logic