Skip to content

Conversation

henriq4
Copy link
Contributor

@henriq4 henriq4 commented Oct 20, 2024

Description of Change

This pull request corrects the recursive factorial function by:

  • Fixing the incorrect exception handling (previously throwing an exception for values less than 20 instead of greater than 20).
  • Ensuring that the function throws an exception when n > 20 to prevent overflow in uint64_t.

Checklist

  • Added description of change
  • Added file name matches File name guidelines
  • Added tests and example, test must pass
  • Added documentation so that the program is self-explanatory and educational - Doxygen guidelines
  • Relevant documentation/comments is changed or added
  • PR title follows semantic commit guidelines
  • Search previous suggestions before making a new one, as yours may be a duplicate.
  • I acknowledge that all my contributions will be made under the project's license.

Notes: This is my first good issue, and I’m grateful to contribute to the project. Fixes #2867

Copy link
Collaborator

@realstealthninja realstealthninja left a comment

Choose a reason for hiding this comment

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

nice spotting! thank you for this.

@realstealthninja realstealthninja added approved Approved; waiting for merge hacktoberfest-accepted Accepted to be counted towards Hacktoberfest labels Oct 22, 2024
@realstealthninja realstealthninja merged commit 94202ec into TheAlgorithms:master Nov 24, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Approved; waiting for merge hacktoberfest-accepted Accepted to be counted towards Hacktoberfest
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Incorrect Exception Handling in Recursive Factorial Function
2 participants