Skip to content

Commit

Permalink
Updated prime_numbers.py testcases. (TheAlgorithms#9851)
Browse files Browse the repository at this point in the history
* Updated prime_numbers.py testcases.

* revert __main__ code.
  • Loading branch information
Muhammadummerr committed Oct 5, 2023
1 parent b76115e commit cffdf99
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions maths/prime_numbers.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ def slow_primes(max_n: int) -> Generator[int, None, None]:
[2, 3, 5, 7, 11]
>>> list(slow_primes(33))
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31]
>>> list(slow_primes(10000))[-1]
9973
>>> list(slow_primes(1000))[-1]
997
"""
numbers: Generator = (i for i in range(1, (max_n + 1)))
for i in (n for n in numbers if n > 1):
Expand All @@ -44,8 +44,8 @@ def primes(max_n: int) -> Generator[int, None, None]:
[2, 3, 5, 7, 11]
>>> list(primes(33))
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31]
>>> list(primes(10000))[-1]
9973
>>> list(primes(1000))[-1]
997
"""
numbers: Generator = (i for i in range(1, (max_n + 1)))
for i in (n for n in numbers if n > 1):
Expand Down Expand Up @@ -73,8 +73,8 @@ def fast_primes(max_n: int) -> Generator[int, None, None]:
[2, 3, 5, 7, 11]
>>> list(fast_primes(33))
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31]
>>> list(fast_primes(10000))[-1]
9973
>>> list(fast_primes(1000))[-1]
997
"""
numbers: Generator = (i for i in range(1, (max_n + 1), 2))
# It's useless to test even numbers as they will not be prime
Expand Down

0 comments on commit cffdf99

Please sign in to comment.