45 lines
927 B
PHP
Raw Permalink Normal View History

2025-01-30 13:08:58 +01:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>Ciąg Fibonacciego</h1>
<form method="post">
<label for="n">Podaj liczbę elementów ciągu: </label>
<input type="number" id="n" name="n" required>
<input type="submit" value="Oblicz">
</form>
<?php
$f[0] = "0";
$f[1] = "1";
$f[2] = "1";
$n = $_POST["n"];
for($i = 2; $i < $n; $i++) {
$f[$i] = $f[$i-1] + $f[$i-2];
}
?>
<table>
<?php
echo "<tr>";
for($i = 0; $i < $n; $i++) {
echo "<th>F<sub>".$i."</sub> </th>";
}
echo "</tr>";
echo "<tr>";
for($i = 0; $i < $n; $i++) {
echo "<th>",$f[$i]." </th>";
}
echo "</tr>";
?>
</table>
</body>
</html>