From 49073eb792ebc9e535331974adce790d2225d163 Mon Sep 17 00:00:00 2001 From: mitomaro Date: Tue, 24 Aug 2021 20:27:17 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=A1=E3=83=A2=E5=8C=96=E3=81=AB=E3=82=88?= =?UTF-8?q?=E3=82=8B=E3=82=A2=E3=83=AB=E3=82=B4=E3=83=AA=E3=82=BA=E3=83=A0?= =?UTF-8?q?=E3=81=AE=E6=94=B9=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app.js b/app.js index bba68419..65086c5d 100644 --- a/app.js +++ b/app.js @@ -2,11 +2,12 @@ const memo = new Map(); memo.set(0, 0); memo.set(1, 1); +memo.set(2, 1); function trib(n) { if (memo.has(n)) { return memo.get(n); } - const value = trib(n - 1) + trib(n - 2); + const value = trib(n - 1) + trib(n - 2) + trib(n - 3); memo.set(n, value); return value; }