mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-04-05 03:29:46 +08:00
fix: incorrect exception handling in factorial function (#2868)
Co-authored-by: realstealthninja <68815218+realstealthninja@users.noreply.github.com>
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user