<?php
function Fibonacci($num){
if ($num == 0)
return 0;
else if ($num == 1)
return 1;
else
return (Fibonacci($num-1) + Fibonacci($num-2));
}
?>
<html>
<head><title>Fibonacci example</title></head>
<body><form action="" method="POST">
Enter Number:<input type="text" name="num"/><br/><br/>
<input type="submit" name="print" value="Print N Fibonacci Numbers"/>
</form>
<?php
if(isset($_POST["print"]))
{
$num = $_POST["num"];
for ($counter = 0; $counter < $num; $counter++){
echo " ".Fibonacci($counter)." ";
}
}
?>
</body></html>
No comments:
Post a Comment