Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add solution for Project-Euler Problem15 #631

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
raklaptudirm merged 4 commits into TheAlgorithms:master from black-tmin-oil:master
Jul 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions Project-Euler/Problem015.js
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// https://projecteuler.net/problem=15
/* Starting in the top left corner of a ×ばつ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 grid?
*/

// A lattice path is composed of horizontal and vertical lines that pass through lattice points.

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
}
console.log(latticePath(20)) // output = 137846528820

AltStyle によって変換されたページ (->オリジナル) /