Here is slow brute force way to find the largest palindromic product of three digit integers. You could do loop and break out of it if you go under the smaller number (the second one) of best solution found so far to be more efficient etc.
Brute force check for largest palindromic product of three number integers
def pali(a):
return str(a) == str(a)[::-1]
print('Biggest palindromic product of two three digit integers is %i, which is %i * %i.' %
max((a*b, a, b) for a in range(999, 100, -1) for b in range(a, 100000//a, -1) if pali(a*b)))
""" Output:
Biggest palindromic product of two three digit integers is 906609, which is 993 * 913.
"""
hughesadam_87 54 Junior Poster
TrustyTony 888 pyMod Team Colleague Featured Poster
hughesadam_87 54 Junior Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.