Skip to content

Commit

Permalink
Update Count-Prime-Numbers.py
Browse files Browse the repository at this point in the history
  • Loading branch information
ShadiShadab authored Jan 10, 2025
1 parent 3b22a47 commit 1e1d958
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions solutions/Count-Prime-Numbers.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
r"""
This module defines the functions `is_prime` and `count_primes` for checking primality
This module defines the functions `is_prime` and `count_primes` for checking primality
and counting prime numbers in a list.
Author: Zeinab Shadabshoar
Date: 09 01 2025
"""


def is_prime(n: int) -> bool:
r"""
Checks if a given number is prime.
Expand Down Expand Up @@ -39,6 +40,7 @@ def is_prime(n: int) -> bool:
return False
return True


def count_primes(numbers: list) -> int:
r"""
Counts the number of prime numbers in a list.
Expand Down Expand Up @@ -66,7 +68,7 @@ def count_primes(numbers: list) -> int:
prime_count += 1
return prime_count


# Example usage
numbers = [25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]
print("Number of prime numbers:", count_primes(numbers))

0 comments on commit 1e1d958

Please sign in to comment.