diff --git a/tools/factorial.py b/tools/factorial.py index 6b38b0d..6e45372 100644 --- a/tools/factorial.py +++ b/tools/factorial.py @@ -3,14 +3,12 @@ # author: @persianflower # example: factorial "5" -> "120" +import math def run(*args) -> str: # args[0] is the first argument, args[1] is the second, etc. # Example with two args: text = args[0], length = int(args[1]) number = int(args[0]) - fact=1 - - while number: - fact*=number - number-=1 + fact = math.factorial(number) return str(fact) +