gcd and primality test