From d718d2e2777d1bd1f0ea4104ba8502248bab890f Mon Sep 17 00:00:00 2001 From: YuJian Date: Fri, 20 May 2022 14:17:55 +0800 Subject: [PATCH] vault backup: 2022-05-20 14:17:55 --- .../算法之美 - 动态规划.md | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/数据结构与算法之美/算法之美 - 动态规划.md b/数据结构与算法之美/算法之美 - 动态规划.md index e12a028..e2ed787 100644 --- a/数据结构与算法之美/算法之美 - 动态规划.md +++ b/数据结构与算法之美/算法之美 - 动态规划.md @@ -2,21 +2,18 @@ ## 用循环实现斐波那契数列 +>实际上是 (n - 1) + (n - 2) + ```javascript const Fibonacci_Cycle = (n: number): number => { if (n <= 0) return 0; if (n === 1) return n; - let n1 = -1; - let n2 = -1; + let n1 = 0; + let n2 = 0; let n3 = 0; for (let index = 0; index <= n; index++) { - if (index === 0) { - n1 = 0; - n2 = 0; - continue; - } if (index === 1) { n1 = 0; n2 = 1;