num_theory.is_prime

Functions

is_prime(n)

Check if a number is prime.

Module Contents

num_theory.is_prime.is_prime(n)[source]

Check if a number is prime.

Parameters:

n (int) – The number to check for primality. Must be a positive integer greater than 1.

Returns:

Returns True if the number is prime, otherwise False.

Return type:

bool

Raises:

ValueError – If the input is not a positive integer greater than 1.

Examples

>>> is_prime(2)
True
>>> is_prime(4)
False
>>> is_prime(13)
True