Code:
<!DOCTYPE html><html>
<body>
<center>
<h1>Perfect, Abundant or Deficient</h1>
<?php
if (isset($_POST['check']))
{
$sum=0;
$dsum=0;
$a=$_POST['num'];
for($i=1;$i<=$a;$i++)
{
if($a%$i==0)
{
$sum=$sum+$i;
}
}
$dsum=2*$a;
if($sum<$dsum)
{
echo "it is a deficient number";
}
else if($sum==$dsum)
{
echo "it is a perfect number";
}
else
{
echo "it is an abundant number";
}
}
?>
<form method="post" action="index.php">
Enter a number: <input type="text" name="num">
<input type="submit" name="check" value="check">
</form>
</center>
</body>
</html>
No comments:
Post a Comment