-
Notifications
You must be signed in to change notification settings - Fork 57
/
Copy pathMain.java
40 lines (36 loc) · 836 Bytes
/
Main.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
package test;
public class Main {
public static void main(String[] args) throws Exception{
int beg = 200000;
int k = 0;
int i;
for(i = beg; i > 0; i--){
if(is2(beg - i)) {
k += 100;
} else {
k--;
}
}
System.out.println(Integer.toString(k));
System.out.println("Finish!");
}
public static boolean is2(long l) {
if (l <= 3) {
if (l > 1) {
return true;
}
return false;
} else if (l % 2 == 0 || l % 3 == 0) {
return false;
} else {
int i = 5;
while (i * i <= l) {
if (l % i == 0 || l % (i + 2) == 0) {
return false;
}
i += 6;
}
return true;
}
}
}