Largest palindrome product - euler project

后端 未结 15 2059
广开言路
广开言路 2020-12-10 22:05

I was trying to solve project Euler problem 4 which is:

A palindromic number reads the same both ways. The largest palindrome made from the product of tw

15条回答
  •  眼角桃花
    2020-12-10 22:42

    Here is the Python code for the Project_Euler-4 problem.

    We have to find the largest palindrome number which is a product of two three digit numbers

    import math
    def isPal(x):
        x=str(x)
        t=x[::-1]
        if(x==t):
            return True
        else:
            return False
    max=0
    for i in range(999,99,-1):
        for j in range(999,99,-1):
            if(isPal(i*j)):
                if((i*j)>max):
                    max=(i*j)
    print(max)
    

    The answer will be 906609

提交回复
热议问题