pub fn fact_vec(x: &[u64]) -> Vec<u64>
Expand description
§fact_vec(x)
Native Function
The fact_vec
function takes a slice of unsigned
64-bit
integers
and returns a vector containing the factorial of each element in the input slice.
It iterates over the input slice, computes the factorial of each element using the fact function,
and collects the results into a vector.
§Examples
use mathlab::math::{fact, fact_vec, u64_to_f64_vec};
let my_x_u64_array = [0, 1, 2, 3, 16, 18];
assert_eq!(fact(3), 6);
assert_eq!(fact(3) as f64, 6.0);
assert_eq!(fact_vec(&my_x_u64_array), [1, 1, 2, 6, 20922789888000, 6402373705728000]);
assert_eq!(fact_vec(&my_x_u64_array).iter().map(|&x| x as f64).collect::<Vec<f64>>(), vec![1.0, 1.0, 2.0, 6.0, 20922789888000.0, 6402373705728000.0]);
assert_eq!(u64_to_f64_vec(&fact_vec(&my_x_u64_array)), [1.0, 1.0, 2.0, 6.0, 20922789888000.0, 6402373705728000.0]);
End Fun Doc