0

(it returns none)---> why?

fact = 1
def factorial(n):
    if (n-1)!=0:
        global fact
        fact=fact*n
        n=n-1
        print(fact)
        factorial(n)
    else:
        return fact
      
n=int(input())
g=factorial(n)
print(g)
  • Please read https://codeblog.jonskeet.uk/2010/08/29/writing-the-perfect-question/ and edit your question to format it suitably, tag it with the language you're using, and provide information about what you've done to diagnose the problem. – Jon Skeet Mar 01 '22 at 15:38
  • Also: https://stackoverflow.com/editing-help – Johnny Mopp Mar 01 '22 at 15:40
  • Does this answer your question? [Recursive function returning none in Python](https://stackoverflow.com/questions/19215141/recursive-function-returning-none-in-python) – Johnny Mopp Mar 01 '22 at 15:42

0 Answers0