GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — JavaScript/Project-Euler/Problem015.js at master · TheAlgorithms/JavaScript Expand file tree/ Copy pathProblem015.jsMore file actions 19 lines (16 loc) · 643 Bytes / Copy pathProblem015.jsFile metadata and controls19 lines (16 loc) · 643 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 // 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? */ // A lattice path is composed of horizontal and vertical lines that pass through lattice points. export const latticePath = (gridSize) => { 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. return paths } // > latticePath(20)) // 137846528820 |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |