Skip to content

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
merged 4 commits into from
Jul 7, 2021
Merged
Changes from 1 commit
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
13 changes: 13 additions & 0 deletions Project-Euler/Problem015.js
Original file line number Diff line number Diff line change
@@ -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++)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add an explanation for your code as comments. The repository is focused on educating people, so it is important that everyone can understand all the code. Refer to #630 for comment format.

c = c * (n + i) / i;
return c;
}
console.log(latticePath(20));