Add doctests to primelib.py (#10242)

* Update primelib.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
cornbread-eater 2023-10-10 14:07:07 -07:00 committed by GitHub
parent 0070739233
commit c850227bee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -574,6 +574,11 @@ def fib(n):
"""
input: positive integer 'n'
returns the n-th fibonacci term , indexing by 0
>>> fib(5)
8
>>> fib(99)
354224848179261915075
"""
# precondition
@ -589,3 +594,9 @@ def fib(n):
fib1 = tmp
return ans
if __name__ == "__main__":
import doctest
doctest.testmod()