Skip to content

Commit

Permalink
fix: incorrect exception handling in factorial function (#2868)
Browse files Browse the repository at this point in the history
Co-authored-by: realstealthninja <68815218+realstealthninja@users.noreply.github.com>
  • Loading branch information
henriq4 and realstealthninja authored Nov 24, 2024
1 parent 769b3c7 commit 94202ec
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion math/factorial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 94202ec

Please sign in to comment.