Exemplo n.º 1
0
bool is_prime(int n)
{
    if(n == 2 || n & 1)
        return (gP(n) != 0);
    
    return false;
}
Exemplo n.º 2
0
void sieve()
{
    memset( prime, -1, sizeof( prime ) );
    unsigned int i;
    unsigned int sqrtN = ( unsigned int )sqrt( ( double )N ) + 1;
    for( i = 3; i < sqrtN; i += 2 )if(gP(i))
    {
        unsigned int i2 = i + i;
        for( unsigned int j = i * i; j < N; j += i2 ) rP( j );
    }
}