PROGRAM
<?php
echo "
<form method='POST' action='' >
Range :<input type='text' name='range'>
<input type='submit' value='submit' name='submit'>
</form>
";
if(isset($_POST['submit']))
{
$n = $_POST['range'];
$checker = $n;
$c=0;
echo $n."STRANGE NUMBERS";
for($num=1;$num<=$n;++$num)
{
$s=0;
$x=$num;
while($x>0)
{
$a = $x%10;
$s = $s+pow($a,3);
$x=$x/10;
}
if($num==$s)
{
echo "<br />".$s;
}
}
}
?>
OUTPUT
<?php
echo "
<form method='POST' action='' >
Range :<input type='text' name='range'>
<input type='submit' value='submit' name='submit'>
</form>
";
if(isset($_POST['submit']))
{
$n = $_POST['range'];
$checker = $n;
$c=0;
echo $n."STRANGE NUMBERS";
for($num=1;$num<=$n;++$num)
{
$s=0;
$x=$num;
while($x>0)
{
$a = $x%10;
$s = $s+pow($a,3);
$x=$x/10;
}
if($num==$s)
{
echo "<br />".$s;
}
}
}
?>
OUTPUT
No comments:
Post a Comment