ISPRIME

This function checks whether an integer is a prime number. A prime is a positive integer greater than 1 with exactly two positive divisors: 1 and itself.

The primality condition can be stated as:

n > 1 \text{ and } \nexists\ d \in \{2,\dots,\lfloor\sqrt{n}\rfloor\} \text{ such that } d \mid n

Negative numbers, 0, and 1 are not prime.

Excel Usage

=ISPRIME(n)
  • n (int, required): Integer to test for primality.

Returns (bool): True if the input is prime, otherwise False.

Example 1: Small prime number check

Inputs:

n
13

Excel formula:

=ISPRIME(13)

Expected output:

true

Example 2: Small composite number check

Inputs:

n
15

Excel formula:

=ISPRIME(15)

Expected output:

false

Example 3: One is not prime

Inputs:

n
1

Excel formula:

=ISPRIME(1)

Expected output:

false

Example 4: Negative integer is not prime

Inputs:

n
-11

Excel formula:

=ISPRIME(-11)

Expected output:

false

Python Code

from sympy import isprime as sympy_isprime

def isprime(n):
    """
    Determine whether an integer is prime.

    See: https://docs.sympy.org/latest/modules/ntheory.html

    This example function is provided as-is without any representation of accuracy.

    Args:
        n (int): Integer to test for primality.

    Returns:
        bool: True if the input is prime, otherwise False.
    """
    try:
        return bool(sympy_isprime(n))
    except Exception as e:
        return f"Error: {str(e)}"

Online Calculator

Integer to test for primality.