From b35104aaa31571b70986d96be6b7212c9356f816 Mon Sep 17 00:00:00 2001 From: Rak Laptudirm Date: Wed, 7 Jul 2021 23:01:34 +0530 Subject: [PATCH] chore: Fix code formatting --- Project-Euler/Problem015.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Project-Euler/Problem015.js b/Project-Euler/Problem015.js index cd20fa204..d35404733 100644 --- a/Project-Euler/Problem015.js +++ b/Project-Euler/Problem015.js @@ -7,9 +7,11 @@ 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) => { - for (var i = 1, paths = 1; i <= gridSize; i++) + let paths + for (let i = 1, paths = 1; i <= gridSize; i++) { + paths = paths * (gridSize + i) / i + } // The total number of paths can be found using the binomial coefficient (b+a)/a. - { paths = paths * (gridSize + i) / i } return paths } console.log(latticePath(20)) // output = 137846528820