# Project Euler #4 Python while loop efficiency

The problem statement for Project Euler Problem 4 is as follows:

A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. Find the largest palindrome made from the product of two 3-digit numbers.

Looking to make this code more efficient. I'm using a variable to pass into the function so that the answer to ints of various lengths can be determined. It's been the most efficient that I've been able to come up with. Any suggestions?

def largestPalindromeProduct(digits):
num=int(digits*"9")
maxPalindrome=0
i=int(num)
floor=int(num/10) if digits > 1 else -1
while i > floor:
j=i
while j > floor:
val=str(i*j)
if val==val[::-1]:
floor=j
maxPalindrome=max(maxPalindrome,i*j)
j-=1
i-=1
return maxPalindrome

print(largestPalindromeProduct(3))
• @stefan Comments are for seeking clarification to the question, and may be deleted. Please put all suggestions for improvements in answers, even if they are brief. – 200_success Feb 16 '18 at 21:57
• I left a comment here with a link to an answer for the eactly same problem. This was deleted. Maybe by @200_success, but I can't be for sure. – stefan Feb 17 '18 at 9:21
• @stefan You can put that same remark and link in an answer. – 200_success Feb 17 '18 at 14:34