Skip to content

Instantly share code, notes, and snippets.

@amoshyc
Created February 7, 2015 13:33
Show Gist options
  • Save amoshyc/f1de4f61e64ceca2091c to your computer and use it in GitHub Desktop.
Save amoshyc/f1de4f61e64ceca2091c to your computer and use it in GitHub Desktop.
Project Euler #4
def is_plaindrome(N):
    temp = N
    rev = 0
    while N is not 0:
        digit = N % 10
        rev = rev * 10 + digit
        N = N // 10

    return temp == rev


print(max([a*b for a in range(100, 1000) for b in range(a, 1000) if is_plaindrome(a*b)]))

不太值得優化…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment