![]() |
|
PHP Fibonacci - Printable Version +- Sinisterly (https://sinister.li) +-- Forum: Coding (https://sinister.li/Forum-Coding) +--- Forum: PHP (https://sinister.li/Forum-PHP) +--- Thread: PHP Fibonacci (/Thread-PHP-Fibonacci) |
PHP Fibonacci - 133720 - 07-29-2013 Last weak ,My friend is call me to challenge about the fibonacci:Frown: he is C# developer :Thumbs-Up: but i will solve with php because i am php web develper :Sarcastic: Here is my Answer with Prof:Innocent: ![]() Source code Code: <html>
<head><title>Fibonacci Challenge</title><head>
<body>
<form action="" method="post">
<input type="text" name="name"/>
<br>
<input type="submit" value="enter"/>
</form>
</body>
</html>
<?php
$first = 0;
$second = 1;
$n =$_POST['name'];
print 'Your input number is = '. $n . '<br/>';
print 'Fibonacci numbers is = '. $first.',';
for($i=1;$i<=$n-1;$i++)
{
$final = $first + $second;
$first = $second;
$second = $final;
print $final . ',';
}
?> |