# Differences

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

 algorithm:factorial_recursive [2013/05/04 14:45]will algorithm:factorial_recursive [2015/02/02 08:28] (current) Both sides previous revision Previous revision 2015/01/29 23:01 will 2015/01/29 23:01 will 2015/01/29 09:20 will 2015/01/29 09:18 will 2014/07/05 22:36 will 2014/05/04 16:25 external edit2013/05/04 14:45 will 2013/04/29 09:29 will 2013/04/29 09:20 will 2012/10/04 22:36 will [Visualisation] 2012/10/04 21:59 external edit2012/09/03 11:37 will created Next revision Previous revision 2015/01/29 23:01 will 2015/01/29 23:01 will 2015/01/29 09:20 will 2015/01/29 09:18 will 2014/07/05 22:36 will 2014/05/04 16:25 external edit2013/05/04 14:45 will 2013/04/29 09:29 will 2013/04/29 09:20 will 2012/10/04 22:36 will [Visualisation] 2012/10/04 21:59 external edit2012/09/03 11:37 will created Line 1: Line 1: - [algorithm factorial_recursive] + ======= λ Factorial - recursive ====== - ====== Algorithm ====== + <​nowiki>​ + ======= Algorithm ​======= function fac(x) { function fac(x) { Line 11: Line 12: ​ - ====== Support ====== + ======= Support ​======= function run() { function run() { Line 18: Line 19: ​ - ====== Options ====== + ======= Tests ======= + + function testTen() { + assert (fac(10) === 3628800, "​fac(10)"​);​ + } + + function testSeven() { + assert (fac(7) === 5040 , "​fac(7)"​);​ + }​ + + ======= Options ​======= { { + "​title":"​Factorial - recursive",​ "​height":"​150px"​ "​height":"​150px"​ } } ​ - ====== Visualisation ====== + ======= Visualisation ​======= <​html>​ <​html>​ Line 38: Line 50: var stack = x.stack; var stack = x.stack; for (var i=stack.length-1;​ i>=0; i--) { for (var i=stack.length-1;​ i>=0; i--) { - var x2 = stack[i].executionContext;​ + var a = stack[i].lookupInScope("​x"​);​ - var a = x2.lookupInScope("​x"​);​ + if (a) { if (a) { html = a+" * "​+html;​ html = a+" * "​+html;​ Line 67: Line 78: ​ +