FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
JavaScript/Project-Euler/Problem015.js at master · TheAlgorithms/JavaScript · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
TheAlgorithms
/
JavaScript
Public
Uh oh!
There was an error while loading.
Please reload this page
.
Notifications
You must be signed in to change notification settings
Fork
5.8k
Star
34.2k
Code
Issues
21
Pull requests
192
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
JavaScript
/
Project-Euler
/
Problem015.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
19 lines (16 loc) · 643 Bytes
Breadcrumbs
JavaScript
/
Project-Euler
/
Problem015.js
Copy path
File metadata and controls
19 lines (16 loc) · 643 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
Back
|
FazBrowse Home
|
New Git URL