Solution to factorial_with_exception