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
upg6.php
28 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 = [];
for ($i = 2; $i <= 100; $i++) {
if (är_primtal($i)) {
$primtal[] = $i;
}
}
echo implode(", ", $primtal) . "\n";
echo "antal: " . count($primtal);
?>