MCPcopy Create free account
hub / github.com/Vishruth-S/CompetitiveCode / factorial

Function factorial

project_euler_problems/lattice paths/solution.js:12–23  ·  view source on GitHub ↗
(n)

Source from the content-addressed store, hash-verified

10 */
11
12function factorial(n) {
13 if (n === 0 || n === 1) {
14 return 1;
15 }
16
17 let sum = 1;
18 for (let i = 2; i <= n; i++) {
19 sum = sum * i;
20 }
21
22 return sum;
23}
24
25function countPaths(gridSize) {
26 return Math.floor(factorial(gridSize * 2) / Math.pow(factorial(gridSize), 2));

Callers 1

countPathsFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected