User Tools

Site Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
factorial [2012/09/03 11:36]
will created
factorial [2015/02/02 08:28] (current)
Line 1: Line 1:
-====== ​Recursive ​====== +====== ​Factorial ​====== 
-:<​math> ​n! = \begin{cases}+If you want to calculate a factorial use the iterative algorithm. The recursive algorithm is included because factorial highlights the differences between iterating and recursing nicely. 
 + 
 +===== Iterative ===== 
 +$$n!=\prod_{k=1}^n k \!$$ 
 + 
 +[algorithm Factorial (iterative)] 
 + 
 +===== Recursive ===== 
 +$$ n! = \begin{cases}
 1 & \text{if } n = 0, \\ 1 & \text{if } n = 0, \\
 (n-1)!\times n & \text{if } n > 0. (n-1)!\times n & \text{if } n > 0.
 \end{cases} \end{cases}
-</​math>​+$$
  
 [algorithm Factorial (recursive)] [algorithm Factorial (recursive)]
- 
-====== Iterative ====== 
-:<​math>​ n!=\prod_{k=1}^n k \!</​math>​ 
- 
-[algorithm Factorial (iterative)] 
- 
factorial.1346697412.txt.gz · Last modified: 2015/02/02 08:24 (external edit)