Created
May 16, 2018 14:28
-
-
Save mentix02/73f8546f1686470378b8558aa8f26dfc to your computer and use it in GitHub Desktop.
a Quora question for checking how many numbers 6 digit numbers are divisible by 495
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
question on quora | |
https://www.quora.com/How-many-6-digit-palindromes-are-divisible-by-495 | |
""" | |
nums = [str(x) for x in range(100000, 1000000)] | |
def check_palindrome(num): | |
if num == num[::-1]: | |
return True | |
else: | |
return False | |
pal_nums = [] | |
for num in nums: | |
if check_palindrome(num): | |
pal_nums.append(num) | |
res = [] | |
for pal_num in pal_nums: | |
if int(pal_num) % 495 == 0: | |
res.append(pal_num) | |
print(len(res)) | |
print(len(res)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment