# Twisted prime number

If given number and reversed number are prime number means that is Twisted prime number.

## Example-1:

```Input    : n = 17
Output   : Twisted prime number
Explain  : 17 is prime number and 71 also prime number.So It's Twisted prime number.
```

## Example-2:

```Input    : n = 23
Output   : Not a Twisted prime number
Output   : 23 is prime number but 32 is not a prime number.So It's Not a Twisted prime
number.
```

# Solution

```public class Main
{
public static void main(String [] args)
{
int num = 13;

if(isPrime(num))
{
int reverse = 0;

while(num!=0)
{
reverse = (reverse*10) + (num%10);

num = num/10;
}

if(isPrime(reverse))
{
System.out.print("Twisted prime number");
}

else
{
System.out.print("Not a Twisted prime number");
}
}

else
{
System.out.print("Not a Twisted prime number");
}
}

public static boolean isPrime(int n)
{
for(int i=2;i<n;i++)
{
if(n % i == 0)
{
return false;
}
}

return true;
}
}
```
```n = 13

m = str(n)[::-1]

m = int(m)

k = 0

for i in range(2,n):

if(n % i == 0):

break

else:

k += 1

for j in range(2,m):

if(m % j == 0):

break

else:

k += 1

if(k==2):

print("Twisted prime number")

else:

print("Not a Twisted prime number")
```

## Output

```Twisted prime number
```