Find prime numbers by JavaScript, gets primes very fast.
![](https://lh3.googleusercontent.com/-KxqvOOa31lE/W1855p1yvvI/AAAAAAAABv4/FasO4v0AsygxU7fyPpWTm0GYu5URKUSigCLcBGAs/s320/primos.png)
<!DOCTYPE html>
<html>
<head><meta charset="utf-8"></head><body>
<script>
datos = window.AppInventor.getWebViewString(); // Entrada de datos.
window.AppInventor.setWebViewString("" + getPrimes(datos)); // Respuesta a CadenaDeWebView
function getPrimes(max) {
var sieve = [], i, j, primes = [];
for (i = 2; i <= max; ++i) {
if (!sieve[i]) {
// i has not been marked -- it is prime
primes.push(i);
for (j = i << 1; j <= max; j += i) {
sieve[j] = true;
}
}
}
return primes;
}
</script>
</body></html>
JS code: https://stackoverflow.com/questions/11966520/how-to-find-prime-numbers-between-0-100