highest palindrome with 3 digit numbers in python

后端 未结 13 1206
梦如初夏
梦如初夏 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:31

    Not the most efficient answer but I do like that it's compact enough to fit on one line.

    print max(i*j for i in xrange(1,1000) for j in xrange(1,1000) if str(i*j) == str(i*j)[::-1])
    

提交回复
热议问题