Thursday 11 February 2016

Check Strange Number or Not

Code:

<!DOCTYPE html>
<html>
<body>
<center>
<h1>STRANGE NUMBER OR NOT</h1>
<?php
if(isset($_POST['check']))
{
$num=$_POST['num'];
$x=$num;
$sum=0;
$e=(string)$num;
$d=strlen($e);
while($x!=0)
{
$a=$x%10;
$sum=$sum+pow($a,$d);
$x=$x/10;
}
if($num==$sum)
{
echo "$num is a strange number";
}
else
{
echo "$num is not a strange number";
}
}

?>
<form method="post" action="index.php">
    Enter limit: <input type="text" name="num">
    <input type="submit" value="Find" name="check">
</form>
</center>
</body>
</html>


Output:


No comments:

Post a Comment