A simple program that I wrote using PHP that will ask the user to give a range from lower bound to upper bound and then our program will generate a series of fibonacci number based on the range that is being specify by our user.
Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
My mobile number here in the Philippines is 09173084360.
Sample Program Output
Program Listing
<html>
<head>
<title>
Range of Fibonacci Numbers
</title>
</head>
<style>
body {
font-family:arial;
font-size :20px;
background-color:lightgreen;
}
input[type=submit]
{
font-size: 20px;
font-weight: bold;
font-family: arial;
background-color: lightblue;
}
</style>
<body>
<?php
error_reporting(0);
$a=$_POST['lower'];
$b=$_POST['upper'];
if(isset($_POST['clear']))
{
$a="";
$b="";
$fib3="";
}
?>
<BR>
<h3>Range in Fibonacci Numbers</h3>
<form method="post" action="index.php" name="prime_me">
Lower Bound <input type="text" name="lower"
size="5" value="<?php echo $a; ?>" autofocus>
Upper Upper Bound <input type="text" name="upper"
size="5" value="<?php echo $b; ?>">
<br><br>
<input type="submit" name="check" value="Ok">
<input type="submit" name="clear" value="Clear">
</form>
<h3> DISPLAY RESULTS </h3>
<?php
if(isset($_POST['check']))
{
$fib1=0;
$fib2=1;
$fib3=0;
$a=$_POST['lower'];
$b=$_POST['upper'];
for($i=$a;$i<$b;$i++)
{
if ($fib3<=$b)
{
if ($fib3>=$a)
{
echo " " .$fib3." ";
}
$fib1=$fib2;
$fib2=$fib3;
$fib3=$fib1+$fib2;
}
}
}
?>
</body>
</html>
No comments:
Post a Comment