A prime number is said to be 'Twisted Prime', if the
new number obtained after reversing the digits is also
a prime number. Write a program to accept a number
and check whether the number is 'Twisted Prime' or
not.
Sample Input: 167
Sample Output: 761
167 is a 'Twisted Prime'.
Answers
Answered by
0
# using python
number =int((input("Enter number")))
def prime_checker(n):
for i in range(2,n):
if n%i==0:
return False
break
return True
if (prime_checker(number)==True):
if (prime_checker(int((str(number)[ : : -1])))==True):
print("number ",number," is twisted prime ")
else:
print("number ", number,"is not twisted prime ")
Similar questions