numbat 1.23.0

A statically typed programming language for scientific computations with first class support for physical dimensions and units.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/// Calculates the factorial of (the floor of) the given `f64`.
///
/// It is the caller's responsibility to ensure that the given `f64` is a
/// non-negative integer.
pub fn factorial(mut x: f64, order: u16) -> f64 {
    debug_assert!(x >= 0.0);
    debug_assert!(order >= 1);
    x = x.floor();
    let mut result = 1f64;
    while x >= 1. && result != f64::INFINITY {
        result *= x;
        x -= order as f64;
    }
    result
}