From db3831401f309d6a8f8c5f424dde7b6a402a168e Mon Sep 17 00:00:00 2001 From: Vodimed <67785939+anna-vodimed@users.noreply.github.com> Date: Sun, 4 Jul 2021 13:53:20 +0000 Subject: [PATCH] Add solution for Project-Euler Problem15 --- Project-Euler/Problem015.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Project-Euler/Problem015.js diff --git a/Project-Euler/Problem015.js b/Project-Euler/Problem015.js new file mode 100644 index 000000000..f33a48b79 --- /dev/null +++ b/Project-Euler/Problem015.js @@ -0,0 +1,13 @@ +// https://projecteuler.net/problem=15 +/* Starting in the top left corner of a 2×2 grid, and only being able to move to +the right and down, there are exactly 6 routes to the bottom right corner. +How many such routes are there through a 20×20 grid? +*/ + +const latticePath = n => { + + for (var i = 1, c = 1; i <= n; i++) + c = c * (n + i) / i; + return c; +} +console.log(latticePath(20));