[BUG] Incorrect Exception Handling in Recursive Factorial Function
henriq4 opened this issue · 1 comments
henriq4 commented
Description
The bug occurs in a recursive factorial function that incorrectly throws an exception when n is less than 20, instead of when n exceeds 20.
Expected behavior
- The function should return the factorial of n for valid inputs between 0 and 20, inclusive.
- If n > 20, an exception should be thrown indicating that the maximum allowable value is 20.
Actual behavior
- The function currently throws an exception if n < 20, which is incorrect.
- Input values of n > 20 are allowed, potentially leading to integer overflow.
Steps to reproduce
- Call factorial(10) or any n less than 20. The function incorrectly throws an exception.
- Call factorial(25). No exception is thrown, but the value is incorrect or may result in integer overflow.
Context
- The function is designed to calculate the factorial of a number n using recursion.
- The valid range of n for uint64_t is 0 <= n <= 20 because the factorial of numbers larger than 20 exceeds the maximum value of a uint64_t.
Additional information
No response
github-actions commented
This issue has been automatically marked as abandoned because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.