diff --git a/index.js b/index.js index 2d7e6834fb6366b3120c7a37cc5f637bc4a33928..1c4e396c97810efa67cc9cd2ae9e618557b5ca80 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