To calculate the factorial of a non-negative integer x, just multiply all the integers from 1 through x. For example:
— factorial(4) would equal 4 * 3 * 2 * 1, which is 24.
— factorial(1) would equal 1.
— factorial(3) would equal 3 * 2 * 1, which is 6.

Instructions

Define a function factorial that takes an integer x as input.

Calculate and return the factorial of that number.

I don’t get how this is supposed to work or what I am meant to do.

From what you have typed or copied & pasted, it says to:

def factorial(x): #define function
#write code to help calculate and return factorial
factorial(5) # call the function. You could also add the print method.

@hermione311 You don’t seem to understand what factorial is. Why don’t you google the concept, and then read the instructions again? Here is a helpful link:

def factorial(x):
while x != 0:
return factorial(x) * factorial(x - 1)
if x == 0:
return 1

Can you help me with this guys? I receive “Oops, try again. factorial(1) resulted in an error: maximum recursion depth exceeded” but don’t really know how to modify the while loop to make this work.