Skip to content

Instantly share code, notes, and snippets.

@hodlbirb
Created February 3, 2017 11:07
Show Gist options
  • Save hodlbirb/d2a895b9c42373bce68f039ad108830b to your computer and use it in GitHub Desktop.
Save hodlbirb/d2a895b9c42373bce68f039ad108830b to your computer and use it in GitHub Desktop.
3 digit palindrome. Output: 997 * 997 = 994009
def main():
memo = 0
x = 0
y = 0
for i in range(1, 999):
for j in reversed(range(1,999)):
temp = i * j
s = str(temp)
if (s[0] == s[-1] and temp > memo):
memo = temp
x = i
y = j
print(str(x) + " * " + str(y) + " = " + str(memo))
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment