Skip to content

fix: validate negative input in factorialRecursive function#2197

Open
REAPER2705 wants to merge 1 commit into
trekhleb:masterfrom
REAPER2705:fix/validate-negative-input-factorial
Open

fix: validate negative input in factorialRecursive function#2197
REAPER2705 wants to merge 1 commit into
trekhleb:masterfrom
REAPER2705:fix/validate-negative-input-factorial

Conversation

@REAPER2705

Copy link
Copy Markdown
  • Add input validation to throw an error for negative numbers
  • Update JSDoc to document the thrown error
  • Prevent incorrect behavior where negative inputs would return 1

- Add input validation to throw an error for negative numbers
- Update JSDoc to document the thrown error
- Prevent incorrect behavior where negative inputs would return 1

@daltino daltino left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR ensures the factorialRecursive function properly validates negative input by throwing an error, which improves its reliability and aligns with mathematical conventions. The change is concise, follows the existing code style, and doesn't introduce issues based on the diff. However, confirm that tests for this validation exist or are added as required by the contribution guidelines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants