# Circular Prime Program in Java

## A circular prime is a prime number with the property that the number generated at each intermediate step when cyclically permuting its digits will be prime. For example, 1193 is a circular prime, since 1931, 9311 and 3119 all are also prime.

```
import java.util.Scanner;
public class CircularPrime
{
public static void main(String[] args)
{
boolean flag = true;
int n, num, r, c = 0;
Scanner sc = new Scanner(System.in);
System.out.print("Enter number=");
n = sc.nextInt();
num = n;
while (num > 0)
{
r = num % 10;
c++;
num = num / 10;
}
num = n;
for (int i = 1; i <= c; i++)
{
r = num % 10;
num = num / 10;
num = (r * (int) Math.pow(10, c - 1)) + num;
if (!prime(num))
{
flag = false;
break;
}
}
if(flag)
{
System.out.println("Circular Prime");
}
else
{
System.out.println("Not Circular Prime");
}
}
static boolean prime(int n)
{
// TODO code application logic here
int i = 2;
boolean flag = true;
while (n > i)
{
if (n % 2 == 0)
{
flag = false;
break;
}
i++;
}
return flag;
}
}
```

#### Output:

Enter number=137 Circular Primeb. tech. bca icse java java tutorials learn java mca programs

### Frequently Asked Questions

##### What is Circular Prime?

A circular prime is a prime number with the property that the number generated at each intermediate step when cyclically permuting its digits will be prime. For example, 1193 is a circular prime, since 1931, 9311 and 3119 all are also prime.

##### What is Circular Prime in Java?

A circular prime is a prime number with the property that the number generated at each intermediate step when cyclically permuting its digits will be prime. For example, 1193 is a circular prime, since 1931, 9311 and 3119 all are also prime.

**Recent Posts**

- Decimal to Binary Number Program in Java July 3, 2021
- Binary to Decimal Number Program in Java July 3, 2021
- Find biggest number from three given numbers Program in C July 2, 2021
- Find quotient and remainder Program in C July 2, 2021
- Print a message if negative number is entered Program in C July 2, 2021
- Print whether a number is even or odd Program in C July 2, 2021
- Print the bigger number Program in C July 2, 2021
- UP Board Class 6 Math अभ्यास - 4(e) सांख्यिकी June 29, 2021
- UP Board Class 6 Math अभ्यास - 4(d) सांख्यिकी June 29, 2021
- UP Board Class 6 Math अभ्यास - 4(c) सांख्यिकी June 29, 2021
- UP Board Class 6 Math अभ्यास - 4(b) सांख्यिकी June 29, 2021
- UP Board Class 6 Math अभ्यास - 4(a) सांख्यिकी June 29, 2021
- UP Board Class 6 Math अभ्यास - 3(f) पूर्णांक PART 2 June 27, 2021
- UP Board Class 6 Math अभ्यास - 3(f) पूर्णांक PART 1 2020 June 27, 2021
- UP Board Class 6 Math अभ्यास - 3(e) पूर्णांक 2020 June 27, 2021
- UP Board Class 6 Math अभ्यास - 3(d) पूर्णांक 2020 June 27, 2021
- UP Board Class 6 Math अभ्यास - 3(c) पूर्णांक 2020 June 27, 2021
- UP Board Class 6 Math अभ्यास - 3(b) पूर्णांक 2020 June 27, 2021
- UP Board Class 6 Math अभ्यास - 3(a) पूर्णांक June 27, 2021
- UP Board Class 6 Math अभ्यास - 2(d) पूर्ण संख्याएँ 2020 June 26, 2021