Skip to content

Instantly share code, notes, and snippets.

@jakedobkin
Created November 12, 2011 17:02
Show Gist options
  • Save jakedobkin/1360817 to your computer and use it in GitHub Desktop.
Save jakedobkin/1360817 to your computer and use it in GitHub Desktop.
Euler 7
<html>
<body>
<script type="text/javascript">
primecount=1;
i=3;
while (primecount < 10001)
{
isprime = true;
for (j=2; j<=Math.sqrt(i); j++)
{
if (i%j == 0)
{
isprime = false;
// document.write(i + "is not prime<br/>");
break;
}
}
if (isprime == true)
{
lastprime=i;
primecount++;
// document.write(i + " is prime number " + primecount + "<br/>");
}
i+=2;
}
document.write(lastprime + " is the " + primecount + "prime number");
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment