Ver Mensaje Individual
  #27 (permalink)  
Antiguo 22/11/2010, 06:19
harbie
 
Fecha de Ingreso: noviembre-2010
Mensajes: 23
Antigüedad: 14 años, 2 meses
Puntos: 0
Respuesta: Por favor alguien me ayuda con este ejercicio?

van a salir mucho errores jeje


<html>
<body>
<table>
<form method="get" action="procesa_numero.php" />
<tr><td>Numero:</td><td><input type="text" name="numero" />(Entre 1 a 40)</td></tr>
<tr><td>Factorial</td><td><input type="radio" name="radio" value="1" /></td></tr>
<tr><td>sumatorio desde 1 hasta el numero</td><td><input type="radio" name="radio"

value="2"/></td></tr>
<tr><td>cuadrado</td><td><input type="radio" name="radio" value="3"/></td></tr>
<tr><td>raiz cuadrada</td><td><input type="radio" name="radio" value="4"/></td><tr>
<tr><td colspan="2" align="center"><input type="submit" value="Enviar" /></td><tr>
</form>
</table>

<?php
if(isset($_GET['numero'])) $numero=(int)$_GET['numero'];
if($numero>=1 && $numero<=40){
else
echo "error, numero no comprendido entre 1 y 40";
}

function factorial($num)
{
$resul = 1;
for($i=1; $i <= $num; $i++)
$resul = $resul * $i;

return $resul;
}

function sumatorio($num)
{
$resul = 0;
for($i=1; $i <= $num; $i++)
$resul = $resul+$i;

return $resul;
}

function cuadrado($num)
{
$resul = $num * $num;
return $resul;
}

echo sqrt($num);

echo $_GET["Factorial"];

?>