Skip to content

Instantly share code, notes, and snippets.

@yuda110
Last active April 27, 2016 09:27
Show Gist options
  • Save yuda110/2bb1371270244442908d15c31d7d0242 to your computer and use it in GitHub Desktop.
Save yuda110/2bb1371270244442908d15c31d7d0242 to your computer and use it in GitHub Desktop.
#python3
def get_palindrome(range_to):
result_sum = 0
for decimal_num in range(range_to):
binary_num = bin(decimal_num)[2:]
if str(decimal_num)== str(decimal_num)[::-1] and str(binary_num)== str(binary_num)[::-1] :
result_sum += decimal_num
return result_sum
print(get_palindrome(1000000))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment