Skip to content

Instantly share code, notes, and snippets.

@cachrisman
Created April 30, 2015 02:30
Show Gist options
  • Save cachrisman/ee16368da4fda8a9b027 to your computer and use it in GitHub Desktop.
Save cachrisman/ee16368da4fda8a9b027 to your computer and use it in GitHub Desktop.
function isPrime(num) {
for ( var i = 2; i < num; i++ ) {
if ( num % i === 0 ) {
return false;
}
}
return true;
}
y = 2
x=confirm("Find the first prime number?")
while (x) {
if (y===2) {
alert("it is "+y)
y++
x=confirm("Find the next prime number?")
} else {
if (isPrime(y)) {
alert("it is "+y)
x=confirm("Find the next prime number?")
}
y++
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment