Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions maths/prime_check.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Prime Check."""
"""PRIME CHECK."""

import math
import unittest
Expand All @@ -7,7 +7,8 @@


def is_prime(number: int) -> bool:
"""Checks to see if a number is a prime in O(sqrt(n)).
"""
Checks to see if a number is a prime in O(sqrt(n)).

A number is prime if it has exactly two factors: 1 and itself.

Expand All @@ -29,14 +30,21 @@ def is_prime(number: int) -> bool:
True
>>> is_prime(67483)
False

If the number entered is not whole number i.e not an integer
For example-
>>> is_prime(16.1)
Traceback (most recent call last):
...
ValueError: is_prime() only accepts positive integers

If the number entered is negative integer
For example-
>>> is_prime(-4)
Traceback (most recent call last):
...
ValueError: is_prime() only accepts positive integers

"""

# precondition
Expand Down
Loading