fn factorial(num: i128) -> i128 {
if num <= 1 {
return 1;
}
return num * factorial(num - 1);
}
fn main() {
let x = factorial(21);
println!("The value of 21 factorial is {}", x);
}
Implementation comes from a C++ recursion example; I hope this will be helpful.