CSE1002 Verification of circular prime number (Id-1051)

CSE1002 Verification of circular prime number
A circular prime number is a prime number 'p' with a property that all the numbers got by cyclically permuting the digits of 'p', are also a prime number.
A number is said to be a prime if it has no factors other than the number 1 and itself. 19937 is a circular prime number, as all the numbers obtained by cyclically permuting the number 19937 : 99371, 93719,37199,71993,19937 are all prime.
Develop an algorithm and write a C program to check if the given number is a circular prime or not.
Input Format
A number
Output Format
Print Circular prime or Not circular prime

C-CODE



INPUT:
The Number 

PROCESSING:
void permut(char *t,int n){
    int i,t1=t[n-1];
    for(i=n-2;i>=0;i--){
        t[i+1]=t[i];
    }   
    t[0]=t1;
    return;
}
int prime(int n){
    int i=2;
    while(i<=n/2){
        if(n%i==0)
            return 0;
        i++;
    }
    return 1;       


OUTPUT:
Print Circular prime or Not circular prime
  
PSUEDO CODE:


1)start
2)read n
3)create function prime(n) which checks if n is prime or not
     int prime(int n){
    int i=2;
    while(i<=n/2){
        if(n%i==0)
            return 0;
        i++;
    }
    return 1;
4)create function permut which return the circular perumated number
void permut(char *t,int n){
    int i,t1=t[n-1];
    for(i=n-2;i>=0;i--){
        t[i+1]=t[i];
    }    
    t[0]=t1;
    return;
5)
    for(i=0;i

Post a Comment

0 Comments