code: public static function FACT($factVal)
      {
          $factVal = Functions::flattenSingleValue($factVal);
  
          if (is_numeric($factVal)) {
              if ($factVal < 0) {
                  return Functions::NAN();
              }
              $factLoop = floor($factVal);
              if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC) {
                  if ($factVal > $factLoop) {
                      return Functions::NAN();
                  }
              }
  
              $factorial = 1;
              while ($factLoop > 1) {
                  $factorial *= $factLoop--;
              }
  
              return $factorial;
          }
  
          return Functions::VALUE();
      }
docs: FACT.
  
  Returns the factorial of a number.
  The factorial of a number is equal to 1*2*3*...* number.
  
  Excel Function:
  FACT(factVal)
  
  @category Mathematical and Trigonometric Functions
  
  @param float $factVal Factorial Value
  
  @return int Factorial