Facebook
From Selin Duru Derindağ, 10 Months ago, written in Python.
Embed
Download Paste or View Raw
Hits: 205
  1. def is_prime(n):
  2.     """Check if a number is prime."""
  3.     if n <= 1:
  4.         return False
  5.     for i in range(2, int(n**0.5) + 1):
  6.         if n % i == 0:
  7.             return False
  8.     return True
  9.  
  10. def find_primes_starting_with_5():
  11.     """Find and display all 3-digit prime numbers starting with 5."""
  12.     primes = []
  13.     for number in range(500, 600):
  14.         if is_prime(number):
  15.             primes.append(number)
  16.     return primes
  17.  
  18. # Run the function and display the results
  19. prime_numbers = find_primes_starting_with_5()
  20. print("3-digit prime numbers starting with 5 are:", prime_numbers)
  21.