-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProblem041.java
More file actions
32 lines (32 loc) · 867 Bytes
/
Copy pathProblem041.java
File metadata and controls
32 lines (32 loc) · 867 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
32
public class Problem41 {
private static boolean isPandigital(int i) {
String iString = String.valueOf(i);
for (int j = 1; j < iString.length() + 1; j++) {
if (!iString.contains(String.valueOf(j))) {
return false;
}
}
return true;
}
private static boolean isPrime(int i) {
for (int j = 2; j <= Math.sqrt(i); j++) {
if (i % j == 0) {
return false;
}
}
return true;
}
public static void main(String[] args) {
boolean found = false;
int i = 7654321;
while (found == false) {
if (isPandigital(i)) {
if (isPrime(i)) {
System.out.println(i);
found = true;
}
}
i -= 2;
}
}
}