Code
def kai(i): #Determine if it is a palindrome
return str(i)[::-1] == str(i)
dec = 11
while not(kai(dec) and kai(bin(dec)[2:]) and kai(oct(dec)[2:])):
dec += 2 #You only have to search for odd numbers (see text)
print(dec)
Binary 0bNN Eighth number 0oNN Hexagon 0xNN
Convert to binary bin (NN) Convert to octal number oct (NN) Convert to hexadecimal hex (NN)
Convert binary numbers to decimal numbers int (BIN, 2) Convert 8 to decimal int (OCT, 2) Convert hexadecimal to decimal int (HEX, 2)
str[::-1]
Reference https://redcat-prog.hatenadiary.org/entry/20111104/1320395840
Recommended Posts