FREE ASSISTANCE FOR THE INQUISITIVE PEOPLE
Tutorial Topics
Write a Java program to transpose of a matrix. JAVA Practical ISC 2016 Solve - Start and End Vowel
JAVA Practical Question ISC 2016 Solve - Circular Prime - Java
2918    Arnab De    09/08/2019

This program is selected from ISC 2016 Computer Science or Class 12 practical paper.

A Circular prime is a prime number that remains a prime under cyclic shifts of its digits. When left most digits is removed and replaced at the end of the remaining string of the 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 1 and itself.

Examples 1:

• 131
• 311
• 113

Hence,131 is a circular prime

Accept a positive number N and check whether it is a circular prime or not. The new number formed after the shifting of the digits should also be displayed.

```import java.util.*;
public class CircularPrime
{
public static void main(String []args)
{
Scanner sc=new Scanner(System.in);
CircularPrime cp=new CircularPrime();
Boolean flag=true;
System.out.print("Enter A Number : ");
int noi=sc.nextInt();
String nos=String.valueOf(noi);
int len=nos.length();

for(int i=1;i<=len;i++)
{
System.out.println(nos);
if(!cp.IsPrime(nos))
{
flag=false;

}
nos=cp.changeNumber(nos);
}
if(flag)
{
System.out.print(noi + " is a Circular Prime No");
}
else
{
System.out.print(noi + " is not a Circular Prime No");
}
}
String changeNumber(String n)
{
String s="";
s=n.substring(1)+n.substring(0,1);
return s;
}
boolean IsPrime(String n)
{
int no=Integer.parseInt(n);
boolean b=true;
int d=2;
while(d<=Math.sqrt(no))
{
if(no%d==0)
{
b=false;
break;
}
d++;
}
return b;
}
}
```

Test with the no 1193
Enter A Number : 197
197
971
719
197 is a Circular Prime No

Test with the no 131
Enter A Number : 131
131
311
113
131 is a Circular Prime No

Test with the no 1193
Enter A Number : 1193
1193
1931
9311
3119
1193 is a Circular Prime No

Test with the no 29
Enter A Number : 29
29
92
29 is not a Circular Prime No

Write a Java program to transpose of a matrix. JAVA Practical ISC 2016 Solve - Start and End Vowel
Author Details
Arnab De
I have over 16 years of experience working as an IT professional, ranging from teaching at my own institute to being a computer faculty at different leading institute across Kolkata. I also work as a web developer and designer, having worked for renowned companies and brand. Through tutorialathome, I wish to share my years of knowledge with the readers.
Enter New Comment
Comment History
No Comment Found Yet.
Imagination is more important than knowledge.
Albert Einstein
558
54.7
Today So Far
Total View (Lakh)
26/05/2018     42637
01/01/2018     36193
25/06/2018     34314
28/06/2017     34308
02/08/2017     32620
01/08/2017     27136
06/07/2017     26963
15/05/2017     26592
14/07/2017     22156
21/04/2018     20848