Published in: PHP
URL: http://en.wikipedia.org/wiki/Fibonacci_number
<?php /** * Example Fibonacci implementation to (n) steps (without recursion) * @return array $req Array of Fibonacci numbers */ function Fibonacci( $steps = 20 ) { do { $inc++; $seq[] = $cur; $add = $cur + $nxt; $cur = $nxt; $nxt = $add; } while ( $inc <= $steps ); return $seq; } // Example of first 50 Fibonacci numbers ?>
Comments
Subscribe to comments
You need to login to post a comment.

Nice. Much faster than my implementation(using recursion--just for fun).