rust_programming_book 0.1.1

Programming works from THE RUST PROGRAMMING LANGUAGE
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/// finds the factorial of the entered number
///
/// # Example
/// ``` let x = 4;
/// let factorial = rust_programming_book::crates::fact(x);
/// assert_eq!(factorial, 24)
/// ```
pub fn fact(x: i32) -> i32 {
    if x == 1 || x == 0 {
        1
    } else {
        x * fact(x - 1)
    }
}