From 2ed4b07bcd33c87d365232e39cd515395f209d91 Mon Sep 17 00:00:00 2001 From: suryas Date: Wed, 17 Sep 2025 14:27:39 -0500 Subject: [PATCH] updated code --- src/arithmetic/arithmetic.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/arithmetic/arithmetic.py b/src/arithmetic/arithmetic.py index 86f6960..cd18c44 100644 --- a/src/arithmetic/arithmetic.py +++ b/src/arithmetic/arithmetic.py @@ -13,7 +13,8 @@ def add_numbers(a: int, b: int) -> int: Returns: Sum of a and b. """ - raise NotImplementedError + return a + b + # raise NotImplementedError def factorial(n: int) -> int: @@ -28,7 +29,16 @@ def factorial(n: int) -> int: Raises: ValueError: if n is negative """ - raise NotImplementedError + if n < 0: + raise ValueError + else: + if n == 0: + return 1 + else: + fact = 1 + for i in range(1, n + 1): + fact = fact * i + return fact def is_prime(n: int) -> bool: @@ -43,4 +53,10 @@ def is_prime(n: int) -> bool: Returns: True if n is prime; otherwise False. """ - raise NotImplementedError + if n <= 1: + return False + else: + for i in range(2, n): + if n % i == 0: + return False + return True \ No newline at end of file