// 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: trueJavaScript Prime Number Check
javascript
Related Posts
More content you might like
Code
python
Python Decorator to Uppercase Result
No preview available for this content.
Jan 26, 2024
Read MoreDiscussion 0
Please sign in to join the discussion.
No comments yet. Be the first to share your thoughts!