0

I tried to input 3, and it would be perfect if it stoped here(picture below), but it kept running for two more steps and turned out outputting 3

a=1
k=0
def factorial(num):
    
    global a
    if num !=k:
        
        a=a*num
        factorial(num-1)
    else:
        return a
        

factorial(int(input()))    

enter image description here

Karl Knechtel
  • 62,466
  • 11
  • 102
  • 153
YI Chen Wang
  • 11
  • 1
  • 2

0 Answers0