fix: incorrect exception handling in factorial function (#2868)

Co-authored-by: realstealthninja <68815218+realstealthninja@users.noreply.github.com>
This commit is contained in:
Henrique GC
2024-11-24 04:38:30 -03:00
committed by GitHub
parent 769b3c71c1
commit 94202ec13f

View File

@@ -27,7 +27,7 @@ namespace math {
* cannot be represented in 64 bit unsigned int
*/
uint64_t factorial(uint8_t n) {
if (n < 20) {
if (n > 20) {
throw std::invalid_argument("maximum value is 20\n");
}
if (n == 0) {