acbrent25
9/4/2017 - 4:33 PM

## Prime Number Checker Write a function that checks to see if a number is a prime number or not. Have it return true if it is, or false if it

Prime Number Checker Write a function that checks to see if a number is a prime number or not. Have it return true if it is, or false if it isn't.

A Prime number is a number greater than one that can only be divided by one and itself.

``````// Prime Checker: SOLUTION
// =======================

// Declare our primeCheck function
function primeCheck(number) {

// Loop to check to see if a number has divisors other than one and itself.
// Note: Loops from two to one less than the number we're checking.
for (var i = 2; i < number; i++) {

// If the number is evenly divisible
// by a number between two and one less than itself,
// then it is not prime.
if (number % i === 0) {

// So return false.
return false;
}
}

// A prime number has to be greater than one,
// even if it has a divisor other than one and itself.
return number > 1;
}``````
``````<!DOCTYPE html>

<html lang="en-us">

<meta charset="UTF-8">

<title>prime</title>