Skip to main content

Posts

Showing posts with the label circular Prime

CIRCULAR/CYCLIC PRIME

PROGRAM : CYCLIC || CIRCULAR PRIME Question: 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 SYNTAX: import java.io.*; class cyclic { static int c,c1,c2,count;//for counting no.of digits     public static void main(String args[])throws IOException     {         BufferedReader br=new BufferedReader(new InputStreamReader(System.i...