Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Challenge4
- {
- def run()
- {
- def max = 1;
- def x, y;
- for (int i = 1; i < 1000; ++i)
- for (int j = i; j < 1000; ++j)
- if (isPalindrome(i*j) && i*j > max) {
- max = i*j; x = i; y = j;
- }
- println max + " ${x}x${y}"
- }
- boolean isPalindrome(int v)
- {
- String str = v as String
- for (int i = 0; i < str.size()/2; ++i)
- if (str[i] != str[-(1+i)])
- return false
- return true
- }
- }
Add Comment
Please, Sign In to add comment