Created
December 11, 2010 11:12
-
-
Save ikr/737318 to your computer and use it in GitHub Desktop.
Factorial function defined for n ∈ [0, 6]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var identity = function (x) { | |
return x; | |
}; | |
var almost_factorial = function (f) { | |
return function (n) { | |
return ( | |
(0 === n)? | |
1 : | |
(n * f(n - 1))); | |
}; | |
}; | |
var factorial6 = | |
almost_factorial( | |
almost_factorial( | |
almost_factorial( | |
almost_factorial( | |
almost_factorial( | |
almost_factorial( | |
almost_factorial(identity))))))); | |
var factorial = almost_factorial(factorial); | |
var show = function () { | |
alert(factorial6(6)); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment