Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 94202ec

Browse files
fix: incorrect exception handling in factorial function (TheAlgorithms#2868)
Co-authored-by: realstealthninja <68815218+realstealthninja@users.noreply.github.com>
1 parent 769b3c7 commit 94202ec

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

math/factorial.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ namespace math {
2727
* cannot be represented in 64 bit unsigned int
2828
*/
2929
uint64_t factorial(uint8_t n) {
30-
if (n < 20) {
30+
if (n > 20) {
3131
throw std::invalid_argument("maximum value is 20\n");
3232
}
3333
if (n == 0) {

0 commit comments

Comments
 (0)