forked from daiwb/Algorithm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path100.java
More file actions
19 lines (18 loc) · 699 Bytes
/
100.java
File metadata and controls
19 lines (18 loc) · 699 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import java.math.BigInteger;
public class Euler {
public static void main(String args[]) {
BigInteger a = BigInteger.valueOf(1);
BigInteger b = BigInteger.valueOf(3);
while (true) {
BigInteger c = b.multiply(BigInteger.valueOf(6)).subtract(a).subtract(BigInteger.valueOf(2));
BigInteger t = c.multiply(c).subtract(c).multiply(BigInteger.valueOf(8)).add(BigInteger.ONE);
t = BigInteger.valueOf((long) ((Math.sqrt(t.doubleValue()) + 1.000000005) / 2));
if (t.longValue() > 1000000000000L) {
System.out.println(c);
return;
}
a = b;
b = c;
}
}
}