Turmrechnen! add to del.icio.us

auch bekannt als Rechenpyramide, Zahlenturm, Ziegelmauer

Meinen Nichten gewidmet! Das hat mich in der Unterstufe immer genervt... ;-)

Anfangswert:

Turmhöhe:

1
2
6
3
1

Preisabfrage für:
[ Elektronik, HiFi & TV | DVDs | Beauty | Heimwerker | Haushalt & Küche | Garten | Audio CDs | Computer & Zubehör | Foto & Zubehör | Software | Videos | Games | Spielsachen | Bücher ]


Das PHP Script:
<!--

/*---------------------------------------*/
/*--  COPYRIGHT MARTIN JAMES THALLER   --*/
/*--            a.k.a. "ONKEL MARTIN"  --*/
/*---------------------------------------*/

//-->
<form name="turm" action="index.php" method="GET">
<p>Anfangswert:<br><input type="text" name="start" value="<?=$_GET["start"]?>"></p>
<p>Turmhöhe:<br><input type="text" name="height" value="<?=$_GET["height"]?>"></p>
<p><input type="submit" value="und los!"></p>
</form>
<table border="0" cellpadding="0" cellspacing="20">
<tr>
	<td><?

    if (isset($_GET["height"]) && isset($_GET["start"]))
    {
        $start = $_GET["start"];

        echo "<table border=\"1\" cellpadding=\"1\" align=\"center\">";

        for($i=1; $i<=$_GET["height"]; $i++)
        {
            $start = $start * $i;
            echo "\n<tr>\n\t<td align=\"center\">".number_format($start,0,",",".")."</td>\n</tr>";
        }

        for($i=2; $i<=$_GET["height"]; $i++)
        {
            $start = $start / $i;
            echo "\n<tr>\n\t<td align=\"center\">".number_format($start,0,",",".")."</td>\n</tr>";
        }

        echo "</table>";
    }

        ?></td>
</tr>
</table>