forked from nayuki/Project-Euler-solutions
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathp015.java
More file actions
26 lines (20 loc) · 793 Bytes
/
p015.java
File metadata and controls
26 lines (20 loc) · 793 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/*
* Solution to Project Euler problem 15
* Copyright (c) Project Nayuki. All rights reserved.
*
* https://www.nayuki.io/page/project-euler-solutions
* https://github.com/nayuki/Project-Euler-solutions
*/
public final class p015 implements EulerSolution {
public static void main(String[] args) {
System.out.println(new p015().run());
}
/*
* This is a classic combinatorics problem. To get from the top left corner to the bottom right corner of an N*N grid,
* it involves making exactly N moves right and N moves down in some order. Because each individual down or right move
* is indistinguishable, there are exactly 2N choose N (binomial coefficient) ways of arranging these moves.
*/
public String run() {
return Library.binomial(40, 20).toString();
}
}