import Foundation // Define a function to check if a number is prime func isPrime(_ n: Int) -> Bool { // Check if the number is less than 2 if n < 2 { return false } // Check if the number is 2 if n == 2 { return true } // Check if the number is even if n % 2 == 0 { return false } // Check odd divisors up to the square root of the number for i in stride(from: 3, through: Int(sqrt(Double(n))), by: 2) { if n % i == 0 { return false } } // If no divisor was found, the number is prime return true } // Loop through all 3-digit numbers starting with 5 for i in 500...599 { // Check if the number is prime if isPrime(i) { // If it is, print it to the console print(i) } }