factorial function, runtime panic



examples/errors/factorial/src/main.rs
fn main() {
    for number in [5, 10, 0, -1, 3] {
        let fact = factorial(number);
        println!("{number}! is {fact}");
    }
}

fn factorial(n:i64) -> i64 {
    if n == 0 {
        return 1;
    }
    n * factorial(n-1)
}

Please type in a number: 5
5! is 120
Please type in a number: 10
10! is 3628800
Please type in a number: -1

thread 'main' has overflowed its stack
fatal runtime error: stack overflow
./rust.sh: line 19: 13666 Aborted                 (core dumped) ./myexe $*