Skip to content

math/sieve_of_eratosthenes: add type hints #2627

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Nov 23, 2020
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion maths/sieve_of_eratosthenes.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@


import math
from typing import List


def sieve(n):
def sieve(n: int) -> List[int]:
"""
Returns a list with all prime numbers up to n.

Expand All @@ -33,6 +34,9 @@ def sieve(n):
[]
"""

if n <= 0:
raise ValueError("Please enter positive integers.")

l = [True] * (n + 1) # noqa: E741
prime = []
start = 2
Expand Down