Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 94202ec

Browse files
henriq4realstealthninja
andauthored
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)

AltStyle によって変換されたページ (->オリジナル) /