post = function(n) {
self.postMessage({reply: true, content: n});
}
findPrime = function(n) {
for (var i = 2; i <= Math.sqrt(n); i += 1) {
if (n % i == 0) {
self.post(0);
}
}
// found a prime!
self.post(n);
}
self.onmessage = function(data) {
findPrime(data);
}
// just say hello
self.post(0);