Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

check prime number c++

bool prime(int a) { 
    if (a < 2)
        return false;
    for (int i = 2; i * i <= a; i++) {
        if (a % i == 0)
            return false;
    }
    return true;
}
 
PREVIOUS NEXT
Tagged: #check #prime #number
ADD COMMENT
Topic
Name
9+6 =