Show sourcecode
The following files exists in this folder. Click to view.
upg1.php
upg2.php
upg3.php
upg4.php
upg5.php
upg6.php
upg7.php
upg7.php
24 lines UTF-8 Windows (CRLF)
<?php
function är_primtal($num) {
if ($num < 2) return false;
for ($i = 2; $i <= sqrt($num); $i++) {
if ($num % $i == 0) {
return false;
}
}
return true;
}
$primtal = [];
$tal = 2;
while (count($primtal)< 100){
if (är_primtal($tal)){
$primtal[] = $tal;
}
$tal++;
}
echo implode(", ", $primtal) . "\n";
echo "antal: " . count($primtal);
?>