From 1c0b5ceda5502e9f291712e3fba209da6772a6bb Mon Sep 17 00:00:00 2001 From: AresnLiang Date: Sun, 4 Feb 2024 15:40:55 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=9F=E4=BA=A7=E4=BB=A3=E7=A0=81=E7=89=87?= =?UTF-8?q?=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 2d7e683..1c4e396 100644 --- a/index.js +++ b/index.js @@ -1 +1,9 @@ -console.log("欢迎来到 InsCode"); \ No newline at end of file +function factorial(n) { + if (n === 0) { + return 1; + } else { + return n * factorial(n - 1); + } +} + +console.log(factorial(5)); // 输出 120 \ No newline at end of file -- GitLab