done with basic calc

This commit is contained in:
2025-02-20 09:59:05 +05:30
parent 57475122a9
commit 7910a25928
9 changed files with 49 additions and 14 deletions

View File

@@ -10,6 +10,14 @@
//
// Use only what you learned! No loops yet, so you'll have to use recursion!
fn factorial(n: u32) -> u32 {
if n == 0 || n == 1 {
return 1;
} else {
return n * factorial(n - 1);
}
}
#[cfg(test)]
mod tests {
use crate::factorial;