forked from Tecmax/JavaAndroidPractise
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathp053.java
More file actions
31 lines (24 loc) · 661 Bytes
/
p053.java
File metadata and controls
31 lines (24 loc) · 661 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
27
28
29
30
31
/*
* Solution to Project Euler problem 53
* Copyright (c) Project Nayuki. All rights reserved.
*
* https://www.nayuki.io/page/project-euler-solutions
* https://github.com/nayuki/Project-Euler-solutions
*/
import java.math.BigInteger;
public final class p053 implements EulerSolution {
public static void main(String[] args) {
System.out.println(new p053().run());
}
public String run() {
BigInteger MILLION = BigInteger.TEN.pow(6);
int count = 0;
for (int n = 1; n <= 100; n++) {
for (int r = 0; r <= n; r++) {
if (Library.binomial(n, r).compareTo(MILLION) > 0)
count++;
}
}
return Integer.toString(count);
}
}