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