javascript
Published on January 26, 2024By DeveloperBreeze
// Function to check if a number is prime
function isPrime(number) {
// Check for divisibility from 2 to number - 1
for (let i = 2; i < number; i++) {
if (number % i === 0) {
return false; // Not a prime number
}
}
return number > 1; // Prime if greater than 1
}
// Check if 13 is a prime number
const result = isPrime(13);
// Display the result
console.log('Is Prime:', result); // Output: Is Prime: true
Comments
Please log in to leave a comment.