Implement factorial solver.