diff --git a/factoriel.php b/factoriel.php new file mode 100755 index 0000000000000000000000000000000000000000..fa51a1215f40fbb52898fe3ff2efa4a76693de52 --- /dev/null +++ b/factoriel.php @@ -0,0 +1,25 @@ +<html> + <head> + <title>M2GPI</title> + </head> + <body> + <form method="POST" action="factoriel.php"> + <input type="submit" name="calcul" value="Calculer"/> + le factoriel de : <input type="number" name="input_value"/> + </form> + <?php + if (isset($_POST['calcul'])) { + + $input_value = $_POST['input_value']; + $factoriel = 1; + + for ($i=$_POST['input_value']; $i > 0 ; $i--) { + echo $factoriel . " * " . $i . "<br>"; + $factoriel = $factoriel * $i; + } + + echo "Le factoriel de " . $_POST['input_value'] . " est " . $factoriel; + } + ?> + </body> +</html>