Skip to content

Commit

Permalink
Update find_prime_numbers.py
Browse files Browse the repository at this point in the history
  • Loading branch information
ShadiShadab authored Jan 11, 2025
1 parent f9270b6 commit 7998a97
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions solutions/find_prime_numbers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
This module defines the function `find_primes_up_to_n` to identify all prime numbers
up to a given integer \( N \). A prime number is greater than 1 and divisible only by 1 and itself.
Author: Zeinab Shadabshoar
Author: Zeinab Shadabshoar
Date: 09 01 2025
"""

Expand All @@ -27,7 +27,7 @@ def is_prime(n: int) -> bool:
"""
# Ensure n is an integer
if not isinstance(n, int):
raise TypeError("Input must be an integer")
raise AssertionError("Input must be an integer")

if n <= 1:
return False
Expand All @@ -53,17 +53,12 @@ def find_primes_up_to_n(n: int) -> list:
"""
# Ensure n is an integer and non-negative
if not isinstance(n, int):
raise TypeError("Input must be an integer")
raise AssertionError("Input must be an integer")
if n < 0:
raise ValueError("Input must be a non-negative integer")
raise AssertionError("Input must be a non-negative integer")

primes = []
for num in range(2, n + 1):
if is_prime(num):
primes.append(num)
return primes


# Example usage
N = 20
print("Prime numbers up to", N, ":", find_primes_up_to_n(N))

0 comments on commit 7998a97

Please sign in to comment.