Add factorial examples in Rust
This commit is contained in:
11
03_recursion/rust/03_factorial/src/main.rs
Normal file
11
03_recursion/rust/03_factorial/src/main.rs
Normal file
@@ -0,0 +1,11 @@
|
||||
fn fact(x: u32) -> u32 {
|
||||
if x == 1 {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return x * fact(x - 1);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
println!("{}", fact(3));
|
||||
}
|
||||
Reference in New Issue
Block a user