From 94202ec13fd89199e48c3f8258e923ad6b276a06 Mon Sep 17 00:00:00 2001 From: Henrique GC <62851165+henriq4@users.noreply.github.com> Date: Sun, 24 Nov 2024 04:38:30 -0300 Subject: [PATCH] fix: incorrect exception handling in factorial function (#2868) Co-authored-by: realstealthninja <68815218+realstealthninja@users.noreply.github.com> --- math/factorial.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/math/factorial.cpp b/math/factorial.cpp index aca1886c7..e350df6bd 100644 --- a/math/factorial.cpp +++ b/math/factorial.cpp @@ -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) {