-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProblem - 4.java
More file actions
40 lines (37 loc) · 877 Bytes
/
Problem - 4.java
File metadata and controls
40 lines (37 loc) · 877 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
33
34
35
36
37
38
39
40
//A palindromic number reads the same both ways.
//The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.
//Find the largest palindrome made from the product of two 3-digit numbers.
package Projecteuler;
class Palendrome {
public static void main(String args[]) {
int a = 999, mult, max = 1;
while (a > 99) {
int b = 999;
while (b > 99) {
mult = a * b;
if (palendromecheck(mult)) {
if (mult > max) {
System.out.println(mult);
max = mult;
break;
}
}
b--;
}
a--;
}
System.out.println(max);
}
public static boolean palendromecheck(int in) {
String org = "" + in;
String rev = "";
for (int i = org.length() - 1; i >= 0; i--) {
rev += org.charAt(i);
}
if (org.equals(rev)) {
return true;
} else {
return false;
}
}
}