fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. long pal = 0;
  13. for(long i = 999; i >= 100; i--) { //Practice: 99 * 99
  14. for(long j = 999; j >= 100; j--) {
  15. long k = i * j; // 9801 999*999 ~= 999006
  16. String normal = String.valueOf(k);//String(9801)
  17. String palindrome = new StringBuffer(normal).reverse().toString();//String(1089)
  18. if (normal.equals(palindrome)) { //False
  19. if (Long.valueOf(normal) > pal) { //Is greater than
  20. pal = Long.valueOf(normal); // pal =
  21. }
  22. }
  23. }
  24. }
  25. System.out.println(pal);
  26. }
  27. }
Success #stdin #stdout 0.25s 99192KB
stdin
Standard input is empty
stdout
906609