Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def check_palindrome(s):
- """Checks whether the given string is palindrome"""
- if s == s[::-1]:
- return True
- product_pal = []
- for i in range (999,900,-1):
- for j in range (999,900,-1):
- product = i * j
- if check_palindrome(str(product)):
- product_pal.append(product)
- print"i =" , i , "j = ",j, "for", product
- print max(product_pal)
- def check_palindrome(s):
- """Checks whether the given string is palindrome"""
- return s == s[::-1]
- max_product = 0
- for i in range(999, 900, -1):
- for j in range(i, 900, -1):
- product = i * j
- if check_palindrome(str(product)):
- max_product = max(max_product, product)
- print "i =", i, "j = ", j, "for", product
- print max_product
- def get_max_three_digit_product():
- max_product = 0
- for i in range(999, 900, -1):
- for j in range(i, 900, -1):
- product = i * j
- if check_palindrome(str(product)):
- max_product = max(max_product, product)
- return max_product
- if __name__ == "__main__":
- print get_max_three_digit_product()
- for i in range(999,99,-1):
- for j in range(999,i-1,-1):
- # check palindrome
- def is_palindrome(n):
- s = str(n)
- return s == s[::-1]
- def get_biggest_palindrome():
- max_product = 0
- for i in xrange(999, 99, -1):
- if max_product >= 999*i:
- # no need to iterate further down
- break
- for j in xrange(999, i-1, -1):
- p = j * i
- if max_product >= p:
- # no need to iterate further down
- break
- if is_palindrome(p):
- max_product = p
- return max_product
Add Comment
Please, Sign In to add comment