Está en la página 1de 2

CODIGO FACTORIAL DE UN NUMERO CAPTURADO POR EL TECLADO

En un archivo de bloc de notas con el nombre factorial.php digita el siguiente cdigo

<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>

También podría gustarte