|
|
@ -1,7 +1,11 @@ |
|
|
|
|
|
|
|
let ve = 0; |
|
|
|
const Fibonacci_Recursion = (n: number): number => { |
|
|
|
const Fibonacci_Recursion = (n: number): number => { |
|
|
|
if (n <= 0) return 0; |
|
|
|
if (n <= 0) return 0; |
|
|
|
if (n === 1) return n; |
|
|
|
if (n === 1) return n; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
++ve; |
|
|
|
|
|
|
|
if (ve >= 2000) throw new Error(`层级过深: ${ve}`); |
|
|
|
|
|
|
|
|
|
|
|
return Fibonacci_Recursion(n - 1) + Fibonacci_Recursion(n - 2); |
|
|
|
return Fibonacci_Recursion(n - 1) + Fibonacci_Recursion(n - 2); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|