Circular Prime number : An easy ISC practical 2016
A number is said to be prime if it has only two factors I and itself.Example:131311113Hence, 131 is a circular prime.Test your program with the sample data and some random data:
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");
}
}
}
Download free Sample papers
Related Posts
Continue learning with these related articles

Logic Gates for ISC Class 11: Truth Tables, Universal Gates, Half and Full Adder
ISC Class 11 Computer Science notes on logic gates: AND, OR, NOT, NAND, NOR, XOR and XNOR with truth tables, why NAND and NOR are universal gates, and half adder and full adder circuits with their Boolean expressions.
Decimal to Binary Conversion in Java: 3 Programs with Examples
How to convert a decimal number to binary on paper and in Java: three programs (String, place value and Integer.toBinaryString), binary to decimal, a dry run and common mistakes.

ISC Class 11 Computer Science Sample Paper 2026-27 with Solutions
A full 70-mark ISC Class 11 Computer Science sample paper for the 2026-27 annual exam: MCQs, number systems, propositional logic, logic gates, Java classes, arrays, strings, searching and sorting, and computing ethics, with complete worked solutions.