Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Il più grande numero palindromo ottenuto dal prodotto di due numeri a due cifre è 9009.
- * Trovare il più grande numero palindromo prodotto di due numeri a tre cifre
- */
- public class main {
- public static void main(String[] args) {
- int b1 = 100;
- int b2 = 100;
- int result = b1*b2;
- for(int i = 100; i < 999; i++) {
- for(int o = 100; o < 999; i++) {
- result = o*i;
- if(isPalindrome(result)) {
- System.out.println("n1: "+ o + " n2: "+ i);
- }
- }
- }
- System.out.println(result);
- }
- private static boolean isPalindrome(int f){
- int v = f;
- String value = Integer.toString(v);
- String reversedValue = "";
- for(int i = value.length()-1; i >= 0; i--) {
- reversedValue += value.charAt(i);
- }
- if(reversedValue.equals(value)) {
- return true;
- }else {
- return false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement