Alright I have an assignment for class to create a simple prime number finding script. I have to create a textbox (done), and a button (done). The script is suppose to tell if the number entered in the box is a prime number (any number between 1 and 999) and alert the user whether it is in the form of a an alert window. I know how to pull out the number from the text box, but I’m supposed to use a ‘for’ loop to some how have the number entered in the text box divided by all numbers up to itself. I cannot figure this out. This is what i have:
for (var i=2; i<1000; i++){
document.prime.primeNumnber.value % i;
document.prime.primeNumber.value % i++;
break;
document.prime.primeNumber.value % document.prime.primeNumber.value;
}
i know that is completely wrong. can someone help me out?