Euler problem number #4

前端 未结 14 1997
萌比男神i
萌比男神i 2021-01-03 11:00

Using Python, I am trying to solve problem #4 of the Project Euler problems. Can someone please tell me what I am doing incorrectly? The problem is to Find the larg

14条回答
  •  悲&欢浪女
    2021-01-03 11:48

    Here is a solution that you might consider. It could be far more efficient but only takes a little time to run.

    largest = 0
    for a in range(100, 1000):
        for b in range(100, 1000):
            c = a * b
            if str(c) == ''.join(reversed(str(c))):
                largest = max(largest, c)
    print(largest)
    

提交回复
热议问题