Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Update prime_numbers.py
  • Loading branch information
cclauss authored Oct 29, 2019
commit 4add0813c56f7e67c882242b4fa5f54b2553120f
22 changes: 13 additions & 9 deletions maths/prime_numbers.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
"""Prime numbers calculation."""


def primes(max):
def primes(max: int) -> int:
"""
Return a list of all primes up to max.
>>> primes(10)
[2, 3, 5, 7]
>>> primes(11)
[2, 3, 5, 7, 11]
>>> primes(25)
[2, 3, 5, 7, 11, 13, 17, 19, 23]
>>> primes(1_000_000)[-1]
999983
"""
max += 1
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add type hints and doctests please as discussed in CONTRIBUTING.md

numbers = [False] * max
ret = []
Expand All @@ -13,12 +24,5 @@ def primes(max):
return ret



def main():
print("Calculate primes up to:\n>> ", end="")
n = int(input())
print(primes(n))


if __name__ == "__main__":
main()
print(primes(int(input("Calculate primes up to:\n>> "))))