blob: ee93a6f08c60e66b0123398ab9dd21638c79b516 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
import gleam/io
pub fn main() {
io.debug(factorial(5))
io.debug(factorial(7))
}
// A recursive functions that calculates factorial
pub fn factorial(x: Int) -> Int {
case x {
// Base case
1 -> 1
// Recursive case
_ -> x * factorial(x - 1)
}
}
|