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;
}
Chat with our AI personalities
#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
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.
[object Object]
No. A given number need not even be divisible by a given prime.
Yes, do write, or if you're too lazy to your homework, use google.
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
The only even prime number is 2.
That's a prime factor.
Any number that cannot be evenly divided by any prime number smaller than itself is a prime number.
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.
prime factor = prime number which can be divided into the given number with no remainder ie 2
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.