prime fn

 #include <iostream>

using namespace std;

void is_prime(int n){

    int counter=0;

    if (n==0 || n==1){

        

        counter=1;

    }

    for (int i =2;i<n;i++){

        if(n%i==0){

            counter = counter+1;

        }

        else{

            counter = counter+0;

           

        }

         

    }

    if(counter==0){

    printf("it is  prime");    

    }

    else{

        printf("It is not prime");

    }

}



int main() {

    int a;

    cout<<"Enter a no. : ";

    cin>>a;

    is_prime(a);

 

  


    return 0;

}

Comments

Popular posts from this blog

Sum of Even Numbers till N

Find the Runner-Up Score!

Print All Substrings