Basic_language_ques/prime_number.cpp
//APPROCH : 2
// root n approch
// Approch 1 can be optimized by using fact that a non prime number has one of its factor between 1 and root of n
// so unless of running a loop of n run till root n
APPROCH : 2
root n approch
Approch 1 can be optimized by using fact that a non prime number has one of its factor between 1 and root of n
so unless of running a loop of n run till root n
APPROCH : 2 root n approch Approch 1 can be optimized by using fact that a non prime number has one of its factor between 1 and root of n so unless of running a loop of n run till root n
int isprime(int n){
	if(n==1)return false;
	if(n==2)return true;
	else {
		for(int i=2;i*i<=n;i++){
			if(n%i ==0)return false;
		}
	}
	return true;
}
int isprime ( int n ) { if ( n == 1 ) return false ; if ( n == 2 ) return true ; else { for ( int i = 2 ; i * i <= n ; i ++ ) { if ( n % i == 0 ) return false ; } } return true ; }
APPROCH : 2
root n approch
Approch 1 can be optimized by using fact that a non prime number has one of its factor between 1 and root of n
so unless of running a loop of n run till root n
APPROCH : 2 root n approch Approch 1 can be optimized by using fact that a non prime number has one of its factor between 1 and root of n so unless of running a loop of n run till root n