maths.prime_sieve_eratosthenes

Sieve of Eratosthenes

Input: n = 10 Output: 2 3 5 7

Input: n = 20 Output: 2 3 5 7 11 13 17 19

you can read in detail about this at https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes

Attributes

user_num

Functions

prime_sieve_eratosthenes(→ list[int])

Print the prime numbers up to n

Module Contents

maths.prime_sieve_eratosthenes.prime_sieve_eratosthenes(num: int) list[int]

Print the prime numbers up to n

>>> prime_sieve_eratosthenes(10)
[2, 3, 5, 7]
>>> prime_sieve_eratosthenes(20)
[2, 3, 5, 7, 11, 13, 17, 19]
>>> prime_sieve_eratosthenes(2)
[2]
>>> prime_sieve_eratosthenes(1)
[]
>>> prime_sieve_eratosthenes(-1)
Traceback (most recent call last):
...
ValueError: Input must be a positive integer
maths.prime_sieve_eratosthenes.user_num