getMessage(); } if ($numObjs < $numInSet) { return Functions::NAN(); } $result = round(MathTrig\Factorial::fact($numObjs) / MathTrig\Factorial::fact($numObjs - $numInSet)); return IntOrFloat::evaluate($result); } /** * PERMUTATIONA. * * Returns the number of permutations for a given number of objects (with repetitions) * that can be selected from the total objects. * * @param mixed $numObjs Integer number of different objects * @param mixed $numInSet Integer number of objects in each permutation * * @return float|int|string Number of permutations, or a string containing an error */ public static function PERMUTATIONA($numObjs, $numInSet) { $numObjs = Functions::flattenSingleValue($numObjs); $numInSet = Functions::flattenSingleValue($numInSet); try { $numObjs = StatisticalValidations::validateInt($numObjs); $numInSet = StatisticalValidations::validateInt($numInSet); } catch (Exception $e) { return $e->getMessage(); } if ($numObjs < 0 || $numInSet < 0) { return Functions::NAN(); } $result = $numObjs ** $numInSet; return IntOrFloat::evaluate($result); } }