-
Notifications
You must be signed in to change notification settings - Fork 1
/
Problem046_GoldbachOtherConjecture.java
39 lines (34 loc) · 1.15 KB
/
Problem046_GoldbachOtherConjecture.java
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
32
33
34
35
36
37
38
39
import java.util.ArrayList;
/**
* Created by Sneeuwpopsneeuw on 16-Aug-16.
*/
public class Problem046_GoldbachOtherConjecture extends Problem{
public static void main(String[] args) {
final int SIZE = 10_000;
boolean flag = false;
ArrayList<Integer> map = new ArrayList<>();
for(int i=1; i < 100; i++) {
map.add(2 * (int)Math.pow(i, 2));
}
for(int i=9; i < SIZE; i++) {
if(i % 2 == 1 && isPrime(i) == false) {
// System.out.println("i = " + i);
for(int j=i-1; j > 0; j--) {
if (isPrime(j)) {
if(map.contains(i-j)) {
System.out.println("i = "+i+" j = "+j+" == "+(i-j));
flag = true;
break;
} else System.out.println("-- i = "+i+" j = "+j);
}
}
if(flag == false) {
System.out.println("ans = " + i);
return;
} else {
flag = false;
}
}
}
}
}