A solution to POJ 1401 Factorial