Advanced primality-checking algorithms