Skip to content
This repository was archived by the owner on Jul 2, 2024. It is now read-only.

Commit 07f07ae

Browse files
committed
Updated primes package
Updated docstrings.
1 parent 43d4197 commit 07f07ae

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

src/primes/func.py

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010
def is_prime(number: int) -> bool:
1111
"""Return prime check result for a specified number
1212
13-
The result of this function is True if a number is prime, otherwise
14-
False.
15-
1613
:param number: number to check
1714
:type number: int
1815
1916
:return: prime check result
2017
:rtype: bool
2118
19+
The result of this function is True if a number is prime, otherwise
20+
False.
21+
2222
"""
2323

2424
if number < 2:
@@ -48,31 +48,30 @@ def get_primes(limit: int) -> List[int]:
4848
def eratosthenes_sieve(limit: int) -> List[int]:
4949
"""Return a list of prime numbers till specified limit
5050
51-
In mathematics, the sieve of Eratosthenes is an ancient algorithm for
52-
finding all prime numbers up to any given limit.
51+
:param limit: a range limit to look for prime numbers
52+
:type limit: int
53+
54+
:return: the list of prime numbers within a specified range
55+
:rtype: list[int]
56+
57+
In mathematics, the sieve of Eratosthenes is an ancient algorithm
58+
for finding all prime numbers up to any given limit.
5359
5460
It does so by iteratively marking as composite (i.e., not prime) the
5561
multiples of each prime, starting with the first prime number, 2.
56-
The multiples of a given prime are generated as a sequence of numbers
57-
starting from that prime, with constant difference between them that is
58-
equal to that prime. This is the sieve's key distinction from using
59-
trial division to sequentially test each candidate number for
60-
divisibility by each prime. Once all the multiples of each discovered
61-
prime have been marked as composites, the remaining unmarked numbers
62-
are primes.
62+
The multiples of a given prime are generated as a sequence of
63+
numbers starting from that prime, with constant difference between
64+
them that is equal to that prime. This is the sieve's key
65+
distinction from using trial division to sequentially test each
66+
candidate number for divisibility by each prime. Once all the
67+
multiples of each discovered prime have been marked as composites,
68+
the remaining unmarked numbers are primes.
6369
6470
This makes this algorithm one of the most efficient approach to find
6571
primes within a range.
6672
6773
.. seealso:: https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes
6874
69-
:param limit: a range limit to look for prime numbers
70-
:type limit: int
71-
72-
:return: the list of prime numbers within a specified range
73-
:rtype: list[int]
74-
75-
7675
"""
7776

7877
sieve: List[bool] = [False, False] + [True] * limit

0 commit comments

Comments
 (0)