highest palindrome with 3 digit numbers in python

后端 未结 13 1208
梦如初夏
梦如初夏 2021-02-01 10:35

In problem 4 from http://projecteuler.net/ it says:

A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-d

13条回答
  •  一向
    一向 (楼主)
    2021-02-01 11:25

    Here is my code to solve this problem.

    lst = []
    for i in range(100,1000): 
        for n in range(2,i) : 
            lst.append (i* n) 
            lst.append(i*i)
    
    lst2=[]
    for i in lst: 
        if str(i) == str(i)[::-1]:
            lst2.append(i)
    print max(lst2) 
    

提交回复
热议问题