Untitled

mail@pastecode.io avatar
unknown
plain_text
3 years ago
254 B
1
Indexable
bool prim(int n){

    int d = 2, cnt = 1;
    while(n > 1){
        int p = 0;
        while(n % d == 0)
            n /= d, p++;
        cnt *= (p + 1);
        d++;
        if(d * d > n)
            d = n;
    }

    return cnt == 2;

}