<jupyter_start><jupyter_text>Day 9 : Recursion 3*<NAME>* ObjectiveToday, we are learning about an algorithmic concept called recursion. Check out the Tutorial tab for learning materials and an instructional video. Recursive Method for Calculating Factorial$$ factorial(N) = \left\{\begin{matrix}1 & N \leq 1 \\N \times factorial(N-1)) & otherwise\end{matrix}\right.$$ Function DescriptionComplete the factorial function in the editor below. Be sure to use recursion.Factorial has the following parameter:- int n; an integer Returns- int: the factorial of $n$**Note:** If you fail to use recursion or fail to name your recursive function factorial or Factorial, you will get a score of $0$ Sample Input        3 Sample Output        6<jupyter_code>#!/bin/python3

import math
import os
import random
import re
import sys

#
# Complete the 'factorial' function below.
#
# The function is expected to return an INTEGER.
# The function accepts INTEGER n as parameter.
#

def factorial(n):
    # Write your code here
    while n!= 0:
        if n == 1:
            return 1
        else:
            return factorial(n - 1) * n

if __name__ == '__main__':
    fptr = open(os.environ['OUTPUT_PATH'], 'w')
    n = int(input().strip())
    result = factorial(n)
    fptr.write(str(result) + '\n')
    fptr.close()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09887640449438202, 'fraction_numerical': 0.009737827715355805, 'mean_word_length': 3.5753424657534247, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '614979', 'license': 'MIT', 'n_tokens_mistral': 409, 'n_tokens_neox': 387, 'n_words': 159, 'path': '30 Days of Challenge/Day 9 - Recursion.ipynb', 'repo_name': 'sohammanjrekar/HackerRank', 'size': '1338'}