isPrime
isPrime is a predicate used in mathematics and computer science to determine whether a given integer n is prime. By definition, a prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. Therefore isPrime(n) yields true if n is prime, and false otherwise. The function is defined for integers; for n <= 1 the result is false.
One common method, known as trial division, tests divisibility of n by integers from 2 up to
For large inputs, practical implementations use probabilistic primality tests such as Miller–Rabin, which can quickly declare
In practice, isPrime is used in prime generation for cryptography, number theory research, and algorithms that