Primality test for calculation boundary