Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Factorial
Factorial
<html> <head> <title>....FACTORIAL....</title> </head> <body bgcolor= "#ffff00" text="#000000"> <center> <h1>.....FACTORIAL.....</h1> <form method="POST" action="factorial2.php"> DIGITE UN NUMERO: <input type="text" name="factor" size=10> <br> <input type="submit" name="cal" value="calcular"> </form> </center> </body>
En un segundo archivo de bloc de notas con nombre factorial2.php digita el siguiente cdigo <html> <head> <title>....FACTORIAL....</title> </head> <body bgcolor= "#ffff00" text="#000000">
<center> <h1>Factorial de un numero</h1> <?php $factorial=$_POST['factor']; echo "<hr>"."1"; $result=1; for($ciclo=2;$ciclo<=$factorial;$ciclo++) { $result=$result*$ciclo; echo " X ".$ciclo; } echo " = ".$result; ?> </center> </body>