Armen Vartan b9a8397f34 files
2014-12-01 12:17:43 -05:00

21 lines
704 B
Markdown

Factorial!
==========
Get the factorial of a given number. Using sys.argv, pass in a number and return it's factorial.
To calculate the factorial of 5, for example, the equation is:
5 * 4 * 3 * 2 * 1 ###120
###Iterative
Write the equation iteratively, using a for or while loop. How to use loops in Python is well documented [here](https://docs.python.org/3.4/tutorial/controlflow.html)
###Recursive
Now write this function recursively. If you run into difficulty, think about how your stack will develop as your function recurses and remember to define your base case.
Write assert statements to test your code in both cases.
[Wikipedia on Factorials](http://en.wikipedia.org/wiki/Factorial)