mirror of
https://hub.njuu.cf/TheAlgorithms/Python.git
synced 2023-10-11 13:06:12 +08:00
Add doctests to prime_check function (#5503)
* added doctests to prime_check function * fix doctests function name
This commit is contained in:
parent
2ddd81df21
commit
07141e4bcc
@ -5,9 +5,28 @@ import unittest
|
||||
|
||||
|
||||
def prime_check(number: int) -> bool:
|
||||
"""Checks to see if a number is a prime.
|
||||
"""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.
|
||||
|
||||
>>> prime_check(0)
|
||||
False
|
||||
>>> prime_check(1)
|
||||
False
|
||||
>>> prime_check(2)
|
||||
True
|
||||
>>> prime_check(3)
|
||||
True
|
||||
>>> prime_check(27)
|
||||
False
|
||||
>>> prime_check(87)
|
||||
False
|
||||
>>> prime_check(563)
|
||||
True
|
||||
>>> prime_check(2999)
|
||||
True
|
||||
>>> prime_check(67483)
|
||||
False
|
||||
"""
|
||||
|
||||
if 1 < number < 4:
|
||||
|
Loading…
Reference in New Issue
Block a user