Hey, why?


Hi guys, I am trying to build a factorial function, but for some reason my “for” does not go through all the numbers in the range(). Ideas?

def factorial(x):
  jerry = x + 1
  if x == 1:
    return 1
    total = 1
    for t in range(1, jerry):
      print t
      total = total * (t+1)
      return total


That line should not be inside the loop.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.