1
<?php
class Fatorial {
function calcular(){
$fat = $_GET['fat'];
$resultado = 1;
for($i = $fat; $i >= 1; $i--){
$resultado *= $fat;
$fat--;
return $resultado;
}
}
}
# Instancia a classe Fatorial()
$c1 = new Fatorial();
# Executa a função
$c1->calcular();
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<title>Questão 2</title>
</head>
<body>
<form method="GET" action="">
Digite um número:
<input type="text" name="fat"><br>
<input type="submit" value="enviar">
</form
</body>
</html>
I believe that if you explain that the problem was only to store the return of the method and the validation of the existence of the value (if I understand correctly), it will greatly improve the answer. It’s that thing: always good to describe what happens in the code or, in this case, the correction that has been made. For a layman, these changes may not be so clear.
– Woss
@Andersoncarloswoss made!
– novic