From 4b3da8b09f615a523bf80ac99020660ae7413245 Mon Sep 17 00:00:00 2001 From: Kento Futatsugami Date: Sat, 11 Sep 2021 10:35:17 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=88=E3=83=AA=E3=83=9C=E3=83=8A=E3=83=83?= =?UTF-8?q?=E3=83=81=E9=96=A2=E6=95=B0=E3=81=AE=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app.js b/app.js index bba68419..ad671cd9 100644 --- a/app.js +++ b/app.js @@ -1,12 +1,13 @@ 'use strict'; const memo = new Map(); memo.set(0, 0); -memo.set(1, 1); +memo.set(1, 0); +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; }