Last active
August 29, 2015 14:15
-
-
Save netojoaobatista/b82368670da882743479 to your computer and use it in GitHub Desktop.
$n primeiros elementos da sequência de Fibonacci utilizando a fórmula de Binet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
foreach (call_user_func(function($n) { | |
for ($x = 1; $x <= $n; ++$x) | |
yield call_user_func(function($x) {return (1/sqrt(5)) * | |
(pow((1+sqrt(5))/2,$x) - pow((1-sqrt(5))/2,$x));}, | |
$x); | |
}, 10) as $n) { | |
var_dump($n); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment