$n1=50; // change this number
for($i=1;$i<=($n1/2); $i++){
if($n1%$i == 0 )
echo " $i," ;
}
echo $n1 ;
$n1=5; // change this number
$factorial=1;
for ($i=1; $i<=$n1;$i++){
$factorial=$factorial*$i;
}
echo "Factorial of $n1 : $factorial";
Output
Factorial of 5 : 120
$n1=$_POST['n1'];
echo "<form method=POST action=''>
<input type=text name=n1 value='$n1'>
<input type=submit value=Submit>
</form>";
$factorial=1;
for ($i=1; $i<=$n1;$i++){
$factorial=$factorial*$i;
}
echo "Factorial of $n1 : $factorial";
function fact($n){
if($n<>1){
$factorial = $n * fact($n-1);
return $factorial;
}else{
return 1;
}
}
echo "Factorial of 6 : ".fact(6);
Output is here
Factorial of 6 : 720
Introduction to PHPSum of digits of a number
Strong Number
Author
🎥 Join me live on YouTubePassionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.