Why am i getting this output

def factorial(x):
  while x > 0:
      for i in range(1,x):
          x = x * i



i am surprised you got output at all. Not sure i want to run your code, looks like an infinity loop

while x > 0 is always going to be true for x=5, so the while loop will cause an infinite number of iterations of your for loop, causing a massive number (i guess the number became so big, python had to stop the loop)


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