-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSolution53.java
More file actions
26 lines (26 loc) · 837 Bytes
/
Copy pathSolution53.java
File metadata and controls
26 lines (26 loc) · 837 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
import java.math.BigInteger;
public class Solution53{
static BigInteger[] factorials(int n){
if(n < 0){
return null;
}
BigInteger[] table = new BigInteger[n+1];
table[0] = BigInteger.valueOf(1);
for(int i = 1; i <= n; ++i){
table[i] = table[i - 1].multiply(BigInteger.valueOf(i));
}
return table;
}
public static void main(String[] args) {
BigInteger[] factorialArr = factorials(100);
int result = 0;
for(int n = 1; n <= 100; n++){
for(int r = 1; r < n; r++){
if(factorialArr[n].divide(factorialArr[r].multiply(factorialArr[n-r])).compareTo(BigInteger.valueOf(1000000)) == 1) {
result++;
}
}
}
System.out.println(result);
}
}