Recursion
main.w
let fact = (n: num): num => {
if n == 0 {
return 1;
}
return n * fact(n - 1);
};
log(fact(7));
Wing console output
# Run locally with wing console
wing it
5040
let fact = (n: num): num => {
if n == 0 {
return 1;
}
return n * fact(n - 1);
};
log(fact(7));
# Run locally with wing console
wing it
5040