answersLogoWhite

0

int is_prime(int n){

int flag=1;

if(n==1)

return 0;

int root=(int)sqrt(n);

while(root!=1){

if(n%root==0){

flag=0;

break;

}

root--;

}

return flag;

}

User Avatar

Wiki User

12y ago

What else can I help you with?

Related Questions

How do you write a program to find whether the given number is prime or not and show output?

#include<stdio.h> #include<conio.h> void main() { int n,a=2; clrscr(); printf("\n enter n"); scanf("%d",&n); if(i<=a-1) { if(a%i==0) { printf("\n the given number is not a prime number"); break; } i++; if(a==i) { printf("\n the given number is a prime number"); } getch(); output: enter the value of n:2 the given number is prime number


With a given big integer number which is the product of two prime numbers how do you find them?

First write a program to generate the prime number. After one prime number was generated, divide the big int number by the prime number. If the remainder is zero then quotient is the second prime number ( also it is important to check whether the quotient is prime number or not because sometimes you will get wrong answer). Repeat the process until you get the result.


Draw a flow chart to check whether a given number is prime or not?

[object Object]


Does a prime number always go an equal number of times?

No. A given number need not even be divisible by a given prime.


Write a c program to find given number is prime or not?

Yes, do write, or if you're too lazy to your homework, use google.


Write a shell script to check whether the given input is prime or not?

shell script for check whether the given no is prime or not??echo "input any number:"read nono=`expr $no`i=`expr 2`while [ $i -lt $no ]doif [ `expr $no % $i` -eq 0];thenecho "$no is not a prime no.."break 2fii=`expr $i +1`doneif [ $i -eq $no ];thenecho "$no is a PRIME no..."fi


What is a prime number that can be divided exactly into the given number?

That's a prime factor.


What is the only given prime number?

The only even prime number is 2.


How can you decide whether a number is a prime number?

Any number that cannot be evenly divided by any prime number smaller than itself is a prime number.


What is the only prime number that is a factor of the number 16?

prime factor = prime number which can be divided into the given number with no remainder ie 2


How are factors and prime numbers related?

Whether a number is a prime number or not is determined by its factors. It is a prime number if its only factors are 1 and itself.


A program to find that the input number is prime or not?

Use Wolfram|Alpha... go to the related link below, Wolfram|Alpha, and type in (is __ (number) prime) and then the program will compute that and tell you if it is prime or composite.