-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCyclicPrimeNumber.java
More file actions
53 lines (52 loc) · 1.15 KB
/
CyclicPrimeNumber.java
File metadata and controls
53 lines (52 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import java.util.*;
class CircularPrime
{
static boolean isprime(int num)
{
boolean flag=true;
for(int a=2;a<=num/2;a++)
{
if(num%a==0)
{
flag=false;
break;
}
}
return(flag);
}
public static void main(String arr[])
{
Scanner sc=new Scanner(System.in);
int num,count=0,temp,base;
System.out.println("Enter any Number");
num=sc.nextInt();
temp=num;
while(temp>0)
{
count++;
temp=temp/10;
}
base=(int)Math.pow(10,count-1);
boolean flag=true;
for(int a=1;a<=count;a++)
{
num=(num%base)*10+(num/base);
if(CircularPrime.isprime(num)==false)
{
flag=false;
break;
}
System.out.println(num);
}
if(flag==true)
{
System.out.println("Number is Circular Prime");
}
else
{
System.out.println("Number is Not Circular Prime");
}
}
}
/**
* @author Pradumn Patel */