diff --git a/src/arithmetic/arithmetic.py b/src/arithmetic/arithmetic.py index 86f6960..4e825c2 100644 --- a/src/arithmetic/arithmetic.py +++ b/src/arithmetic/arithmetic.py @@ -13,7 +13,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 +28,12 @@ def factorial(n: int) -> int: Raises: ValueError: if n is negative """ - raise NotImplementedError + if n < 0: + raise ValueError("n must be a non-negative integer") + if n == 0 or n == 1: + return 1 + else: + return n * factorial(n - 1) def is_prime(n: int) -> bool: @@ -43,4 +48,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(n**0.5) + 1): + if n % i == 0: + return False + return True