From 606c871fe6c5f505abc5f8da9cc705e415c732d1 Mon Sep 17 00:00:00 2001 From: Phillip Date: Wed, 1 Jan 2025 22:45:07 -0600 Subject: [PATCH] Update find-factorial.md Use Python's built-in factorial function --- snippets/python/math-and-numbers/find-factorial.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/snippets/python/math-and-numbers/find-factorial.md b/snippets/python/math-and-numbers/find-factorial.md index 939e8fa6..23a28ac9 100644 --- a/snippets/python/math-and-numbers/find-factorial.md +++ b/snippets/python/math-and-numbers/find-factorial.md @@ -3,13 +3,14 @@ title: Find Factorial description: Calculates the factorial of a number. author: dostonnabotov tags: python,math,factorial,utility +contributors: starryknight64 --- ```py +import math + def factorial(n): - if n == 0: - return 1 - return n * factorial(n - 1) + return math.factorial(n) # Usage: print(factorial(5)) # Output: 120