-7

I'm having trouble figuring out how does this exactly work. Can anyone please explain?

def fact(x):
    if x == 0:
        return 1
    return x * fact(x - 1)

x=int(raw_input())
print fact(x)
timgeb
  • 76,762
  • 20
  • 123
  • 145
Martin
  • 1
  • 1

1 Answers1

0

It gets the factorial of the value x. The value of x is whatever you enter since x = int(raw_input) gets the user input. For example if x=3, then fact(3) will be 3×2=6....

bixhopm
  • 1
  • 2