Problem 36
The decimal number, 585 = 10010010012 (binary), is palindromic in both bases.
Find the sum of all numbers, less than one million, which are palindromic in base 10 and base 2.
(Please note that the palindromic number, in either base, may not include leading zeros.)
# 寻找所有既是2进制回文数又是10进制回文数的整数之和
i = 1
lst = []
sum1 = 0
while i < 1000000:
string1 = str(i)
string2 = bin(i)[2:]
if string1 == string1[::-1] and string2 == string2[::-1]:
lst.append(i)
sum1 += i
i += 1
print(sum1)
print(lst)