Fibonacci sequence: Difference between revisions
Content deleted Content added
Added EchoLisp |
|||
Line 3,409:
where
a = ( 5*f^3 + if even n then 3*f else (- 3*f) ) -- 3n
d = ( 5*g^3 + if even n then (- 3*g) else 3*g ) -- 3(n+1) (*)▼
b = ( g^3 + 3 * g * f^2 - f^3 ) -- 3n+1
c = ( g^3 + 3 * g^2 * f + f^3 ) -- 3n+2
▲ d = ( 5*g^3 + if even n then (- 3*g) else 3*g ) -- 3(n+1) (*) </lang>
<code>(fibN2 n)</code> directly calculates a pair <code>(f,g)</code> of two consecutive Fibonacci numbers, <code>(Fib[n], Fib[n+1])</code>, from recursively calculated such pair at about <code>n/3</code>:
<lang haskell> *Main> take 10 $ show $ fst $ fibN2 (10^6)
|