From e6a1a34546794e966097616b0f71756ac4836b87 Mon Sep 17 00:00:00 2001 From: rtang09 <49603415+rtang09@users.noreply.github.com> Date: Mon, 9 Oct 2023 23:18:56 -0700 Subject: [PATCH 1/2] Update primelib.py added cases --- maths/primelib.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/maths/primelib.py b/maths/primelib.py index cf01750cf912..e4037e31c176 100644 --- a/maths/primelib.py +++ b/maths/primelib.py @@ -38,7 +38,7 @@ """ from math import sqrt - +import doctest from maths.greatest_common_divisor import gcd_by_iterative @@ -46,6 +46,15 @@ def is_prime(number: int) -> bool: """ input: positive integer 'number' returns true if 'number' is prime otherwise false. + + >>> is_prime(97) + True + >>> is_prime(9991) + False + >>> is_prime(-3) + Traceback (most recent call last): + ... + AssertionError: 'number' must been an int and positive """ # precondition @@ -589,3 +598,6 @@ def fib(n): fib1 = tmp return ans + +if __name__ == "__main__": + doctest.testmod() From 0fa033e24895a6a5540272eb592f7ab8f08d83db Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 10 Oct 2023 06:24:07 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- maths/primelib.py | 1 + 1 file changed, 1 insertion(+) diff --git a/maths/primelib.py b/maths/primelib.py index e4037e31c176..92ebb5006627 100644 --- a/maths/primelib.py +++ b/maths/primelib.py @@ -599,5 +599,6 @@ def fib(n): return ans + if __name__ == "__main__": doctest.testmod()