How to Calculate a Factorial Using Python

Python

 1|  def calculate_factorial(n):
 2|      factorial = 1
 3|      for j in range(n, 0, -1):
 4|          factorial *= j
 5|      return factorial
 6|  
 7|  print(calculate_factorial(5))
Did you find this snippet useful?

Sign up for free to to add this to your code library