highest palindrome with 3 digit numbers in python

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

    Here is my Python code:

    max_pal = 0
    for i in range(100,999):
        for j in range(100,999):
          mult = i * j 
          if str(mult) == str(mult)[::-1]: #Check if the number is palindrome
              if mult > max_pal: 
                  max_pal = mult
    print (max_pal)
    

提交回复
热议问题