在 Pascal 中,递归方法可以有多个基本案例吗?

Can a recursive method have more than one base case in Pascal?

我想知道您是否可以在 Pascal 的递归 procedure/function 上拥有不止一个基本案例。 如果是这样,你能给我一个简单的例子吗?请解释为什么这是可能的?

简单的斐波那契数列有两个基本情况:

f(0) = 0
f(1) = 1
f(n) = f(n - 1) + f(n - 2)

当然,您也可以用 Pascal 编写:

function Fib(n: integer): integer;
begin
  if n = 0 then Fib := 0
  else if n = 1 then Fib := 1
  else Fib := Fib(n - 1) + Fib(n - 2)
end;