Remove live code & console.log, leave examples as comments (ProjectEuler, Recursive).

This commit is contained in:
Eric Lavault
2021-10-10 18:18:25 +02:00
parent 9212e6d684
commit 5f45b540b9
17 changed files with 48 additions and 98 deletions

View File

@ -6,7 +6,7 @@ How many such routes are there through a 20×20 grid?
// A lattice path is composed of horizontal and vertical lines that pass through lattice points.
const latticePath = (gridSize) => {
export const latticePath = (gridSize) => {
let paths
for (let i = 1, paths = 1; i <= gridSize; i++) {
paths = paths * (gridSize + i) / i
@ -14,4 +14,6 @@ const latticePath = (gridSize) => {
// The total number of paths can be found using the binomial coefficient (b+a)/a.
return paths
}
console.log(latticePath(20)) // output = 137846528820
// > latticePath(20))
// 137846528820