worker.js
434 Bytes
onmessage = function (event) {
var arguments = JSON.parse(event.data);
run(arguments.start, arguments.end);
};
function run(start, end) {
var n = start;
while (n < end) {
var k = Math.sqrt(n);
var found = false;
for (var i = 2; !found && i <= k; ++i) {
found = n % i === 0;
}
if (!found) {
postMessage(n.toString());
}
n++;
}
}