Create A Mechanism To Pass In A Positive Integer And Display All The Values Of The Fibonacci Series Up To And Including The Specified Value
Solution 2:
<labelfor="powerof">Fibonacci: </label><inputtype="text"name="powerof"value="<?phpecho$_GET['powerof']; ?>"/><inputtype="submit"name='Go'value="Calculate" /></fieldset></form><?php$message = 'The fibonacci sequence is: <br />1<br />2<br />';
$powerof = 0;
$max = 10;
$temp = $max;
if (isset($_GET['powerof'])) {
$powerof = $_GET['powerof'];
}
if ($powerof > 100) {
$powerof = 100;
$message = 'Sorry, your input was too high. I converted it to the maximum value of 100.<br />The fibonacci sequence is: <br />1<br />2<br />';
}
$x = 0;
$y = 1;
$z = 0;
$counter = 0;
while ($counter < $powerof) {
if ($counter <= 1) {
$z = 1;
} else {
$z = $x + $y;
}
echo($z."<br />");
$x = $y;
$y = $z;
$counter++;
}
?>
this is the working version
Post a Comment for "Create A Mechanism To Pass In A Positive Integer And Display All The Values Of The Fibonacci Series Up To And Including The Specified Value"