Horje
check prime cpp gfg Code Example
check prime cpp gfg
bool isPrime(int s){
   if(s <= 1) return false;
   if(s == 2) return true;
   for(int i = 2; i * i <= s; i++) {
       if(s % i== 0) return false;
   }
   return true;
}
fast way to check if a number is prime C++
//O(sqrt(n))
bool isPrime(int num){
    if(num <= 1) return false;
    for(int i = 2; i <= sqrt(num); i++){
          if(num % i == 0) return false;
    }
    return true;
}




Cpp

Related
Setting a number of decimals on a float on C++ Code Example Setting a number of decimals on a float on C++ Code Example
stl reverse sort a array Code Example stl reverse sort a array Code Example
concatenate two vectors c++ Code Example concatenate two vectors c++ Code Example
insert only unique values into vector Code Example insert only unique values into vector Code Example
cin exceptions c++ Code Example cin exceptions c++ Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
11