In [29]:
def multiplifier(*user_input):
product = 1 # Identity property, any number of things times 0 is 0
for term in user_input:
print "%d * %d" % (product, term)
product *= term # multiply the accumulator value by a term and store
return product
In [9]:
multiplifier(1, 2, 3, 4)
Out[9]:
In [33]:
def factorialize(factor):
return multiplifier(*list(range(1, factor+1))[::-1])
In [34]:
factorialize(5)
Out[34]:
In [ ]: