I have been learning rust while practicing recursion. So this is just a simple recursive problem and the type is an signed8 and should be working. But I get this error which I am not able to understand why.
The base case is correct and the calls recursive calls are correct as well.
fn main() {
let num = ways_to_climb(10);
println!("{}", num);
}
fn ways_to_climb(n: i8) -> i8 {
println!("{}", n);
if n == 0 || n == 1 {
return 1;
}
if n < 0 {
return 0;
}
return ways_to_climb(n - 1) + ways_to_climb(n - 2) + ways_to_climb(n - 3);
}