pub fn factorial(arg: &Expression) -> ExpressionExpand description
Factorial function n!
§Mathematical Definition
n! = n × (n-1) × (n-2) × … × 2 × 1 0! = 1 by convention
§Arguments
arg- Expression to compute factorial of
§Returns
Factorial expression
§Examples
use mathhook_core::functions::special::factorial::factorial;
use mathhook_core::{expr, Expression};
// Factorial returns BigInteger, so we check it's a number
let result = factorial(&Expression::integer(0));
assert!(matches!(result, Expression::Number(_)));
let result2 = factorial(&Expression::integer(5));
assert!(matches!(result2, Expression::Number(_)));