I just write this algorithm that searches for prime palindromic (both binary and decimal) number, but I got an error:
Traceback (most recent call last):
File "python", line 25, in <module>
File "python", line 10, in isPalindromic
TypeError: not all arguments converted during string formatting"
I can't understand where is my fault. Also I'm not sure if this works, but for me (I'm new in programming) sounds logical.
import math
def isPalindromic():
n = 10
while True:
for i in range(3, int(math.sqrt(n)) + 1):
if n % i != 0:
n = str(n)
new_number = n[::-1]
if n == new_number:
n = int(n)
binary = str(bin(n)[2:])
binary_new = binary[::-1]
if binary == binary_new:
return n
n = int(n)
n = n + 1
a = isPalindromic()