DeveloperBreeze

JavaScript Prime Number Check

javascript
// 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

Continue Reading

Discover more amazing content handpicked just for you

Code
python

Python Decorator to Uppercase Result

No preview available for this content.

Jan 26, 2024
Read More
Code
php

Generate the Fibonacci series

No preview available for this content.

Jan 26, 2024
Read More

Discussion 0

Please sign in to join the discussion.

No comments yet. Start the discussion!