From fba082869363009b385021dbea8c186df01038cc Mon Sep 17 00:00:00 2001 From: Sanil-Surve Date: Thu, 20 Jun 2024 19:37:55 +0530 Subject: [PATCH 1/3] Solved Issue 1008 --- src/algorithms/math/factorial/factorialRecursive.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/algorithms/math/factorial/factorialRecursive.js b/src/algorithms/math/factorial/factorialRecursive.js index e2b4aec6..2b21bc91 100644 --- a/src/algorithms/math/factorial/factorialRecursive.js +++ b/src/algorithms/math/factorial/factorialRecursive.js @@ -1,7 +1,11 @@ /** * @param {number} number * @return {number} + * @throws {Error} if number is negative */ export default function factorialRecursive(number) { + if (number < 0) { + throw new Error('Factorial is not defined for negative numbers.'); + } return number > 1 ? number * factorialRecursive(number - 1) : 1; } From 39552b63a219497715f3c85fcab167c3efdf9b7a Mon Sep 17 00:00:00 2001 From: Sanil-Surve Date: Thu, 20 Jun 2024 19:47:01 +0530 Subject: [PATCH 2/3] Initial commit --- src/algorithms/math/factorial/README.en-IN.md | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/algorithms/math/factorial/README.en-IN.md diff --git a/src/algorithms/math/factorial/README.en-IN.md b/src/algorithms/math/factorial/README.en-IN.md new file mode 100644 index 00000000..df2e290b --- /dev/null +++ b/src/algorithms/math/factorial/README.en-IN.md @@ -0,0 +1,35 @@ +# Factorial + +_Read this in other languages:_ +[_简体中文_](README.zh-CN.md), [_Français_](README.fr-FR.md), [_Türkçe_](README.tr-TR.md), [_ქართული_](README.ka-GE.md), [_Українська_](README.uk-UA.md). + +In mathematics, the factorial of a non-negative integer `n`, +denoted by `n!`, is the product of all positive integers less +than or equal to `n`. For example: + +``` +5! = 5 * 4 * 3 * 2 * 1 = 120 +``` + +| n | n! | +| --- | ----------------: | +| 0 | 1 | +| 1 | 1 | +| 2 | 2 | +| 3 | 6 | +| 4 | 24 | +| 5 | 120 | +| 6 | 720 | +| 7 | 5 040 | +| 8 | 40 320 | +| 9 | 362 880 | +| 10 | 3 628 800 | +| 11 | 39 916 800 | +| 12 | 479 001 600 | +| 13 | 6 227 020 800 | +| 14 | 87 178 291 200 | +| 15 | 1 307 674 368 000 | + +## References + +[Wikipedia](https://en.wikipedia.org/wiki/Factorial) \ No newline at end of file From 2208c5415fb52735148b5666bf9c7fc0a677f032 Mon Sep 17 00:00:00 2001 From: Sanil-Surve Date: Thu, 20 Jun 2024 20:02:51 +0530 Subject: [PATCH 3/3] Initial commit --- CONTRIBUTING.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8f6bf079..61856a81 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -8,8 +8,7 @@ **Contributing New Translation** -- Create new `README.xx-XX.md` file with translation alongside with -main `README.md` file where `xx-XX` is [locale and country/region codes](http://www.lingoes.net/en/translator/langcode.htm). +- Create new `README.xx-XX.md` file with translation alongside with main `README.md` file where `xx-XX` is [locale and country/region codes](http://www.lingoes.net/en/translator/langcode.htm). For example `en-US`, `zh-CN`, `zh-TW`, `ko-KR` etc. - You may also translate all other sub-folders by creating related `README.xx-XX.md` files in each of them.