Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
27
Task/Factorial/JavaScript/factorial-4.js
Normal file
27
Task/Factorial/JavaScript/factorial-4.js
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
(function () {
|
||||
'use strict';
|
||||
|
||||
// factorial :: Int -> Int
|
||||
function factorial(x) {
|
||||
|
||||
return range(1, x)
|
||||
.reduce(function (a, b) {
|
||||
return a * b;
|
||||
}, 1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// range :: Int -> Int -> [Int]
|
||||
function range(m, n) {
|
||||
var a = Array(n - m + 1),
|
||||
i = n + 1;
|
||||
|
||||
while (i-- > m) a[i - m] = i;
|
||||
return a;
|
||||
}
|
||||
|
||||
|
||||
return factorial(18);
|
||||
|
||||
})();
|
||||
Loading…
Add table
Add a link
Reference in a new issue