Quotes help make search much faster. Example: "Practice Makes Perfect"

Thursday, November 29, 2012

Codecademy: factorial


#sample solution


def factorial(x):
x = abs(x) #prevents error on negative numbers
product = 1
for i in range(x):
product = product * (i+1)
return product

print factorial(10)

No comments:

Post a Comment


This is an example of scrolling text using Javascript.

Popular Posts