Code:
<!DOCTYPE html><html>
<body>
<center><h1>Fibonacci Numbers in your Range</h1>
<?php
if (isset($_POST['find']))
{
$fib1=0;
$fib2=1;
$fib3=0;
$lower=$_POST['lower'];
$upper=$_POST['upper'];
for($i=$lower;$i<$upper;$i++)
{
if ($fib3<=$upper)
{
if ($fib3>=$lower)
{
echo "$fib3 <br/>";
}
$fib1=$fib2;
$fib2=$fib3;
$fib3=$fib1+$fib2;
}
}
}
?>
<form method="post" action="index.php">
Enter lower limit: <input type="text" name="lower">
Enter upper limit: <input type="text" name="upper">
<input type="submit" value="Find" name="find">
</form>
</center>
</body>
</html>
No comments:
Post a Comment