-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProblem206.java
More file actions
24 lines (23 loc) · 770 Bytes
/
Problem206.java
File metadata and controls
24 lines (23 loc) · 770 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
public class Problem206 {
private static boolean isForm(String s) {
boolean form = true;
for (int i = 0; i < 9; i++) {
form = form && String.valueOf(i + 1).equals(
s.substring(2 * i, 2 * i + 1));
}
form = form && s.substring(18).equals("0");
return form;
}
public static void main(String[] args) {
long low = (long) Math.ceil(Math.sqrt(1020304050607080900L));
long high = (long) Math.floor(Math.sqrt(1929394959697989990L));
boolean found = false;
while(!found && low < high) {
found = isForm(String.valueOf(low * low));
if (found) {
System.out.println(low);
}
low++;
}
}
}