From d88bb42e5d087b175d9051982b40979453393ca2 Mon Sep 17 00:00:00 2001 From: YuJian Date: Mon, 30 May 2022 15:37:17 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=92=E5=BD=92=E5=B1=82=E7=BA=A7=E9=99=90?= =?UTF-8?q?=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dynamic programming/Fibonacci_Recursion.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Dynamic programming/Fibonacci_Recursion.ts b/Dynamic programming/Fibonacci_Recursion.ts index cac027e..6fefb42 100644 --- a/Dynamic programming/Fibonacci_Recursion.ts +++ b/Dynamic programming/Fibonacci_Recursion.ts @@ -1,7 +1,11 @@ +let ve = 0; const Fibonacci_Recursion = (n: number): number => { if (n <= 0) return 0; if (n === 1) return n; + ++ve; + if (ve >= 2000) throw new Error(`层级过深: ${ve}`); + return Fibonacci_Recursion(n - 1) + Fibonacci_Recursion(n - 2); };