<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def factorial(n):
 """ Factorial function that works with really big numbers. """

  if isinstance(n, float):
    if n.is_integer():
      n = int(n)
  if not isinstance(n, INT_TYPES):
    raise TypeError("Non-integer input (perhaps you need Euler Gamma "
                    "function or Gauss Pi function)")
  if n < 0:
    raise ValueError("Input shouldn't be negative")
  return reduce(operator.mul,
                it.takewhile(lambda m: m <= n, it.count(2)),
                1)