Possible Duplicate:
Function for Factorial in Python
I need to write a program in python that returns N!, without using the factorial function. I have a program written so far but I keep getting an error saying, local variable "fact" is assigned but never used
. How do I use fact = 1
, after it is assigned?
from pylab import *
def factorial(n):
fact = 1
for i in range(n):
print("i = ", i)
fact = fact * i
print("The factorial of " + str(n) + " is: " + str(fact))