Skip to content

Latest commit

 

History

History
22 lines (16 loc) · 403 Bytes

is-a-number-prime-5262119038c0985a5b00029f.md

File metadata and controls

22 lines (16 loc) · 403 Bytes

Solutions for "Is a number prime?"

Kata Link: Is a number prime?

JavaScript

function isPrime(number) {
    let sqrt = Math.sqrt(number);

    for(let i = 2; i <= sqrt; i++) {
        if (number % i === 0) return false;
    }

    return number > 1;
}