Counting primes in Javascript

This is a companion to this test page which counts primes in Flash and Silverlight.

Note that with a high number you will likely get a "Stop running this script" or "Unresponsive script" alert, which wrecks the test. See here for an explanation and fix, for IE and FireFox.

Number for which to count primes:

Click to count the primes

For comment and discussion see here.