79079003

Date: 2024-10-11 16:15:47
Score: 1
Natty:
Report link
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.

Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: 315732