Guest User

Untitled

a guest
Jan 21st, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. # Find the largest palindrome made from the product of two 3-digit numbers.
  2.  
  3. def isPalindrome(N):
  4. strN = str(N)
  5. if strN == strN[::-1]:
  6. return True
  7. return False
  8.  
  9. def main():
  10. N = 1000
  11.  
  12. largest, i = 0, 100
  13. while i < N:
  14. j = i
  15. while j < N:
  16. candidate = i * j
  17. if candidate > largest and isPalindrome(candidate):
  18. largest = candidate
  19. j += 1
  20. i += 1
  21.  
  22. print largest
  23.  
  24. if __name__ == "__main__":
  25. main()
Add Comment
Please, Sign In to add comment