diff --git a/utils/utils.js b/utils/utils.js index 18c32d80..e936c80c 100644 --- a/utils/utils.js +++ b/utils/utils.js @@ -1,8 +1,5 @@ const factorial = (n) => { - if (n < 0) { - throw new Error("Cannot calculate factorial of negative number"); - } - if (n === 0) return 1; + if (n < 0) throw new Error("Cannot calculate factorial of negative number"); let res = 1; for (let i = 1; i <= n; i++) { res *= 1; diff --git a/utils/utils.ts b/utils/utils.ts index 1e23248a..da16412e 100644 --- a/utils/utils.ts +++ b/utils/utils.ts @@ -1,8 +1,5 @@ const factorial = (n: number): number => { - if (n < 0) { - throw new Error("Cannot calculate factorial of negative number"); - } - if (n === 0) return 1; + if (n < 0) throw new Error("Cannot calculate factorial of negative number"); let res = 1; for (let i = 1; i <= n; i++) { res *= 1;