PPY_PRIMECHECK

This function uses the primePy package to test whether an integer is prime.

A prime number is an integer greater than 1 that has exactly two positive divisors. The function returns a boolean indicating whether the input satisfies this property.

It provides a lightweight alternative implementation to other primality tests.

Excel Usage

=PPY_PRIMECHECK(num)
  • num (int, required): Integer to test for primality.

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

Example 1: primePy check for prime integer

Inputs:

num
17

Excel formula:

=PPY_PRIMECHECK(17)

Expected output:

true

Example 2: primePy check for composite integer

Inputs:

num
21

Excel formula:

=PPY_PRIMECHECK(21)

Expected output:

false

Example 3: primePy check for even non-prime

Inputs:

num
100

Excel formula:

=PPY_PRIMECHECK(100)

Expected output:

false

Example 4: primePy check for larger prime

Inputs:

num
997

Excel formula:

=PPY_PRIMECHECK(997)

Expected output:

true

Python Code

from primePy import primes as primepy_primes

def ppy_primecheck(num):
    """
    Check primality using the primePy implementation.

    See: https://github.com/janaindrajit/primePy

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

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

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

Online Calculator

Integer to test for primality.