<prompt> Andika kazi Python ambayo inachukua idadi na anarudi factorical ya idadi hiyo.  <response>: Here is a Python function that calculates the factorial of a given number:pythondef factorialn: if n 0: return 1 else: return n factorialn - 1This function takes one argument n, which is the integer for which the factorial needs to be calculated. The function uses recursion to calculate the factorial. If the value of the function argument n is 0, then the function returns 1. Otherwise, it returns the result of multiplying n and the factorial of n-1.Heres an example usage of the function:pythonnum 5result factorialnumprintfThe factorial of num is result Output: The factorial of 5 is 120 