• Share

### Your suggestion is on its way!

An email with a link to:

was emailed to:

Thanks for sharing About.com with others!

##### Most Emailed Articles

&quot;Big Five&quot; Personality Quiz

### Prime Number Calculator <!-- This script and many more are available free online at --> <!-- The JavaScript Source!! http://javascript.internet.com --> <!-- Begin function calculate(form) { var num=parseInt(form.number.value); if (isNaN(num) || num < 0) { form.result.value=(form.number.value + " is not a valid number! Try again!"); } if (num == 1 || num == 2) { form.result.value=(num + " is prime!"); } for (var i=2;i<num;i++) { if (num % i == 0) { var prime="yes"; form.result.value=(num + " is not prime. It is divisible by " + i + "."); break; } if (num % i != 0) var prime="no"; } if (prime == "no") form.result.value=(num + " is prime!"); } // End --> Where was this tool when I was in school?

Prime numbers only have two divisors, one and itself. 3 is a prime number as only 1 and 3 are its divisors. 7 is also a prime number. 4 is not as it has 1, 2 and 4 as its divisors. Small prime numbers are relatively easy to find, the larger primes are not. That is exactly why this calculator comes in handy. Simply enter your number and click on calculate to determine if the number you entered is prime.

### Prime Number Calculator

Free JavaScripts provided
by The JavaScript Source