edlang/programs/factorial.ed

15 lines
254 B
Rust
Raw Normal View History

2024-02-14 10:21:33 +00:00
mod Main {
pub fn main() -> i32 {
2024-02-16 10:09:49 +00:00
let b: i32 = factorial(4);
2024-02-14 10:21:33 +00:00
return b;
}
2024-02-16 11:49:12 +00:00
pub fn factorial(n: i32) -> i32 {
2024-02-14 10:21:33 +00:00
if n == 1 {
return n;
} else {
return n * factorial(n - 1);
}
}
}