**Watch java videos**

#### A **Circular Prime** is a prime number that remains prime under cyclic shifts of its digits. When the leftmost digit is removed and replaced at the end of the remaining string of digits, the generated number is still prime. The process is repeated until the original number is reached again.

A number is said to be prime if it has only two factors I and itself.**Example:**

131

311

113

Hence, 131 is a circular prime.

Test your program with the sample data and some random data:

**Example 1****INPUT :**N = 197**OUTPUT:**

197

971

719

197 IS A CIRCULAR PRIME **Example 2****INPUT :**N = 1193**OUTPUT:**

1193

1931

9311

3119

1193 IS A CIRCULAR PRIME**Example 3****INPUT :**N = 29**OUTPUT:**

29

92

29 IS NOT A CIRCULAR PRIME

```
import java.io.*;
class circular_prime
{
static int isPrime(int x,int j)
{
int count=0;
while(j<=x)
{
if(x%j==0)
{
count++;
}
j++;
}
return count;
}
static int checkCircular(int num)
{
int c=0;
int n=num;
String a=Integer.toString(num);
int len=a.length();
int b=(int)Math.pow(10,(len-1));
for(int i=0;i<len;i++)
{
int rem=n%10;
int rev=rem*b;
int temp=rev+(n/10);
n=temp;
if(isPrime(temp,1)==2)
{
c++;
}
}
if(c==len)
{
return 1;
}
else
{
return 0;
}
}
public static void main()throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter a number");
int number=Integer.parseInt(br.readLine()); if(checkCircular(number)==1)
{
System.out.println("CIRCULAR PRIME NUMBER");
}
else
{
System.out.println("NOT A CIRCULAR PRIME NUMBER");
}
}
}
```