Rust Factorial

Published 361d ago

 nptester

Recursive factorial function in Rust

fn factorial(n: u64) -> u64 {
    if n == 0 {
        1
    } else {
        n * factorial(n - 1)
    }
}

factorialrecursionRust
1

Please login or sign up to comment and collaborate