<?php
do {
echo "Digite um número natural: ";
$n = (int) trim(fgets(STDIN));
} while($n < 0);
for ($i = 1, $n_fatorial = 1; $i <= $n; $n_fatorial *= $i++);
echo "\nO fatorial do número {$n} é: {$n_fatorial}.";
?>
To embed this project on your website, copy the following code and paste it into your website's HTML: