trekhleb / javascript-algorithms

📝 Algorithms and data structures implemented in JavaScript with explanations and links to further readings
MIT License
185.07k stars 29.85k forks source link

throw-error-for-negative-factorial #1011

Closed Devesh35 closed 11 months ago

Devesh35 commented 1 year ago

Issue: Factorial of a negative number does not exist #1008 Added condition to throw an error for negative numbers in factorial. Also added test cases to validate the results.