package ProjectEuler;
public class Problem04 {
public static void main(String[] args) {
assert solution1(10000) == -1;
assert solution1(20000) == 19591;
assert solution1(30000) == 29992;
assert solution1(40000) == 39893;
assert solution1(50000) == 49894;
assert solution1(60000) == 59995;
assert solution1(70000) == 69996;
assert solution1(80000) == 79897;
assert solution1(90000) == 89798;
assert solution1(100000) == 99999;
}
private static int solution1(int n) {
for (int i = n - 1; i >= 10000; --i) {
String strNumber = String.valueOf(i);
if (new StringBuilder(strNumber).reverse().toString().equals(strNumber)) {
for (int divisor = 999; divisor >= 100; --divisor) {
if (i % divisor == 0 && String.valueOf(i / divisor).length() == 3) {
return i;
}
}
}
}
return -1;
}
}