algolib.maths.number_theory package
Submodules
algolib.maths.number_theory.prime module
- algolib.maths.number_theory.prime.is_prime(n: int) bool [source]
Check whether an integer is a prime using the \(6k \pm 1\) optimization.
- Parameters:
n (int) – Non-negative integer to test.
- Returns:
True if n is prime; False otherwise.
- Return type:
bool
- Raises:
InvalidTypeError – If n is not int.
InvalidValueError – If n is negative.
Module contents
- algolib.maths.number_theory.is_prime(n: int) bool [source]
Check whether an integer is a prime using the \(6k \pm 1\) optimization.
- Parameters:
n (int) – Non-negative integer to test.
- Returns:
True if n is prime; False otherwise.
- Return type:
bool
- Raises:
InvalidTypeError – If n is not int.
InvalidValueError – If n is negative.