# Differences

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

 algorithm:factorial_iterative [2013/04/13 19:03]will algorithm:factorial_iterative [2015/02/02 08:28] (current) Both sides previous revision Previous revision 2015/01/29 23:01 will 2015/01/29 09:17 will 2014/07/05 22:36 will 2014/05/04 16:25 external edit2013/05/04 14:34 will 2013/04/29 09:56 will 2013/04/29 09:31 will 2013/04/13 19:33 will 2013/04/13 19:33 will 2013/04/13 19:03 will 2013/04/13 19:02 will 2013/04/13 19:02 will 2012/10/04 22:36 will [Visualisation] 2012/10/04 21:59 external edit2012/09/03 11:38 will created Next revision Previous revision 2015/01/29 23:01 will 2015/01/29 09:17 will 2014/07/05 22:36 will 2014/05/04 16:25 external edit2013/05/04 14:34 will 2013/04/29 09:56 will 2013/04/29 09:31 will 2013/04/13 19:33 will 2013/04/13 19:33 will 2013/04/13 19:03 will 2013/04/13 19:02 will 2013/04/13 19:02 will 2012/10/04 22:36 will [Visualisation] 2012/10/04 21:59 external edit2012/09/03 11:38 will created Line 1: Line 1: - [algorithm factorial ​iterative] + ======= λ Factorial - iterative ​====== - ====== Algorithm ====== + <​nowiki>​ + ======= Algorithm ​======= function fac(x) { function fac(x) { Line 12: Line 13: ​ - ====== Support ====== + ======= Support ​======= function run() { function run() { - fac(50); + ​return ​fac(50); } } ​ - ====== Visualisation ====== + ======= Tests ======= + + function testTen() { + assert (fac(10) === 3628800, "​fac(10)"​);​ + } + + function testSeven() { + assert (fac(7) === 5040 , "​fac(7)"​);​ + }​ + + ======= Options ======= + + { + "​title":"​Factorial - iterative",​ + "​height":"​150px"​ + } + ​ + + ======= Visualisation ​======= <​html>​ <​html>​ Line 29: Line 48: var html = "";​ var html = "";​ if (r) { if (r) { - html = "n = " + r; + html = ""​ + r; } } else { else { var n = x.lookupInScope("​n"​);​ var n = x.lookupInScope("​n"​);​ var i = x.lookupInScope("​i"​);​ var i = x.lookupInScope("​i"​);​ - ​if (n && i) { + html = i? "i = "​+i+"<​br>" ​: "<​br>";​ - ​html = "i = "​+i+"<​br>"​+"​n = " + n; + if (n) { + html += "n = " + n; } } } } Line 42: Line 62: ​ - + ​ ​ +