trekhleb / javascript-algorithms

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

Update factorial.js #1100

Closed ihemanthm closed 3 months ago

ihemanthm commented 5 months ago

updated the factorial program to work with Negative Numbers also.

ihemanthm commented 4 months ago

I don't think so as the factorial of 0 is 1.So error will be thrown only when the number is less than 0.