From 85816782e061935e79b3b71b830e07b03a6a1836 Mon Sep 17 00:00:00 2001 From: MitchellHansen Date: Fri, 22 Jan 2016 00:45:57 -0800 Subject: [PATCH] new file: problem_4.py --- problem_4.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 problem_4.py diff --git a/problem_4.py b/problem_4.py new file mode 100644 index 0000000..c0fc66f --- /dev/null +++ b/problem_4.py @@ -0,0 +1,24 @@ +import math + + +def isPalindrome(number): + num_str = str(number) + + if len(num_str) % 2 != 0: + return False + + for i in range(0, int(len(num_str) / 2)): + if num_str[i] != num_str[len(num_str) - (i + 1)]: + return False + + return True + + +largest_number = 0 + +for x in range(0, 999): + for y in range(0, 999): + if isPalindrome(x * y) and largest_number < x * y: + largest_number = x * y + +print(largest_number) \ No newline at end of file