From 07141e4bcce7770300f4cf7c3042bdfc5e3c9934 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Murilo=20Gon=C3=A7alves?= <38800183+murilo-goncalves@users.noreply.github.com> Date: Fri, 22 Oct 2021 14:14:27 -0300 Subject: [PATCH] Add doctests to prime_check function (#5503) * added doctests to prime_check function * fix doctests function name --- maths/prime_check.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/maths/prime_check.py b/maths/prime_check.py index e2bcb7b8f..92d31cfee 100644 --- a/maths/prime_check.py +++ b/maths/prime_check.py @@ -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: