We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2f1cb5f commit 647b899Copy full SHA for 647b899
maths/prime_check.py
@@ -7,6 +7,15 @@
7
8
9
def is_prime(number: int) -> bool:
10
+ """
11
+ Check whether a given integer is a prime number.
12
+
13
+ :param n: integer to check
14
+ :return: True if n is prime, False otherwise
15
+ :raises ValueError: if n is less than 2
16
17
+ if n < 2:
18
+ raise ValueError("n must be an integer greater than or equal to 2")
19
"""Checks to see if a number is a prime in O(sqrt(n)).
20
21
A number is prime if it has exactly two factors: 1 and itself.
0 commit comments