Webbserverprogrammering 1

Show sourcecode

The following files exists in this folder. Click to view.

webbsrvprg/ovningar/

index.php
ovn_gr1.php
ovn_gr2.php
ovn_gr3for.php
ovn_gr3while.php
ovn_gr4.php
ovn_gr5.php
ovn_gr6.php
ovn_gr7.php

ovn_gr7.php

34 lines ASCII Windows (CRLF)
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>grunder 7</title>
</head>
<body>
    
</body>
</html><?php

$antal 
= 0;
$tal = 2;

while (
$antal < 100) {
    
$primtal = true;

    for (
$i = 2; $i < $tal; $i++) {
        if (
$tal % $i == 0) {
            
$primtal = false;
            break;
        }
    }

    if (
$primtal) {
        echo 
$tal . "<br>";
        
$antal++;
    }

    
$tal++;
}

?>