From 527c4743b0c04222acd4c84bac6baa9be579e662 Mon Sep 17 00:00:00 2001 From: fkskfana Date: Sun, 12 Jul 2026 16:57:45 +0530 Subject: [PATCH 1/2] fix: clean up factorial logic and move import #208 --- tools/factorial.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/tools/factorial.py b/tools/factorial.py index 6b38b0d..ee7c81e 100644 --- a/tools/factorial.py +++ b/tools/factorial.py @@ -2,15 +2,10 @@ # description: Find factorial of number # 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 - return str(fact) + number = int(args[0]) + fact = math.factorial(number) + return str(fact) \ No newline at end of file From f4a1310777c8c097b84256f48356d8e03c599135 Mon Sep 17 00:00:00 2001 From: fkskfana Date: Thu, 16 Jul 2026 22:00:20 +0530 Subject: [PATCH 2/2] Fix formatting and ensure consistent indentation --- tools/factorial.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tools/factorial.py b/tools/factorial.py index ee7c81e..6e45372 100644 --- a/tools/factorial.py +++ b/tools/factorial.py @@ -2,10 +2,13 @@ # description: Find factorial of number # author: @persianflower # example: factorial "5" -> "120" -import math + +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 = math.factorial(number) - return str(fact) \ No newline at end of file + number = int(args[0]) + fact = math.factorial(number) + return str(fact) +