Zeigt die alle Primzahlen von 0 bis? An
Code
<head>
</head>
<body>
</body>
<script>
function getPrimzahlen(upperFront) {
var nPrim = new Array( );
for( x = 0; x <= upperFront; x++ ) {
nPrim[x] = false;
}
x = 2;
while( ( x * x ) <= upperFront ) {
if( nPrim[x] == false ) {
for( y = ( x * x ); y <= upperFront; y += x ) {
nPrim[y] = true;
}
}
x++;
}
console.log(nPrim)
for( x = 2; x <= upperFront; x++ ) {
if( nPrim[x] == false ) {
document.getElementsByTagName('body')[0].innerHTML+=x+'<br>';
}
}
}
getPrimzahlen(111)
</script>