fork download
  1. def fact(n):
  2. space = ' ' * (5 * n)
  3. print(space, 'factorial', n)
  4. if n == 0:
  5. print(space, 'returning', 1)
  6. return 1
  7. else:
  8. result = n * fact(n-1)
  9. print(space, 'returning', result)
  10. return result
  11.  
  12. fact(5)
  13.  
Success #stdin #stdout 0.02s 8964KB
stdin
Standard input is empty
stdout
                          factorial 5
                     factorial 4
                factorial 3
           factorial 2
      factorial 1
 factorial 0
 returning 1
      returning 1
           returning 2
                returning 6
                     returning 24
                          returning 120