Last updated 1 year ago
Was this helpful?
GoMelan supports recursivity.
fn factorial(n: Int) -> Int { if (n <= 1) { return 1; } else { return n * factorial(n - 1); } } fn main() -> Int { return factorial(5); }
Output:
120
Declare the factorial function.
Recursively calculating the factorial of n.
Call the factorial function in main with n=5.
For more information on recursivity, please visit .