diff --git a/README.md b/README.md index af2eb1b..74aee94 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,9 @@ 1. Fork this repository to your own GitHub account. 2. Create a new branch from `develop` and name it `feature/student1name_student2name`. 3. Clone the repo to AWS VM. -4. Implement the functions until all `pytest` tests pass. -5. Push your code to your Github repo. -5. Submit a Pull Request back to the `develop` branch of the main repo. CI must pass. -6. Wait for code review and grading. +4. Run poetry install to install dependencies. +5. Run poetry run pre-commit install to install the pre-commit hook. +6. Implement the functions until all `pytest` tests pass. Commit and pass pre-commit checks. +7. Push your code to your Github repo. +8. Submit a Pull Request back to the `develop` branch of the main repo. CI must pass. +9. Wait for code review and grading. diff --git a/src/arithmetic/arithmetic.py b/src/arithmetic/arithmetic.py index 86f6960..e150edd 100644 --- a/src/arithmetic/arithmetic.py +++ b/src/arithmetic/arithmetic.py @@ -2,6 +2,8 @@ from __future__ import annotations +import math + def add_numbers(a: int, b: int) -> int: """Return the sum of two integers. @@ -13,7 +15,7 @@ def add_numbers(a: int, b: int) -> int: Returns: Sum of a and b. """ - raise NotImplementedError + return a + b def factorial(n: int) -> int: @@ -28,7 +30,9 @@ def factorial(n: int) -> int: Raises: ValueError: if n is negative """ - raise NotImplementedError + if n < 0: + raise ValueError() + return math.factorial(n) def is_prime(n: int) -> bool: @@ -43,4 +47,9 @@ def is_prime(n: int) -> bool: Returns: True if n is prime; otherwise False. """ - raise NotImplementedError + if n <= 1: + return False + for i in range(2, int(math.sqrt(n)) + 1): + if n % i == 0: + return False + return True