We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6506531 commit e33cfc2Copy full SHA for e33cfc2
maths/primality/sieve_of_eratosthenes.py
@@ -3,6 +3,19 @@
3
# This method is suitable for n up to about 10**7 on typical hardware.
4
5
def sieve_of_erastosthenes(n):
6
+ """
7
+Compute all prime numbers up to and including n using the Sieve of Eratosthenes.
8
+Parameters
9
+----------
10
+n : int
11
+ Upper bound (inclusive) of the range in which to find prime numbers.
12
+ Expected to be a non-negative integer. If n < 2 the function returns an empty list.
13
+Returns
14
+-------
15
+list[int]
16
+ A list of primes in ascending order that are <= n.
17
18
+
19
20
#Boolean list to track prime status of numbers
21
prime = [True] * (n + 1)
0 commit comments