Solution
def reverse(number): result = 0 while number > 0: result = result * 10 + (number % 10) number = int(number / 10) return result def is_palindrome(number): return number == reverse(number) largestPalindrome = 0 a = 999 while a >= 100: if a % 11 == 0: b = 999 db = 1 else: b = 990 db = 11 while b >= a: if a*b <= largestPalindrome: break if is_palindrome(a*b): largestPalindrome = a*b b = b-db a = a-1 print largestPalindrome
No comments:
Post a Comment