Add factorial examples in Rust

This commit is contained in:
Alexander Launi
2020-03-21 16:20:51 -04:00
parent 64e231a8c6
commit 2aa26293b0
3 changed files with 30 additions and 0 deletions

View 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));
}