Jump to content

Fibonacci sequence: Difference between revisions

m (FutureBasic entry moved out of the Basic group)
Line 10,418:
 
===Binary powering===
This is an efficient method (similar to the one used internally by <code>fibonacci()</code>), although running it without compilation won't give competitive speed.
<syntaxhighlight lang="parigp">fib(n)={
if(n<=0,
Line 10,491 ⟶ 10,492:
a
};</syntaxhighlight>
 
===Trigonometric===
This solution uses the complex hyperbolic sine.
<syntaxhighlight lang="parigp">fib(n)=real(2/sqrt(5)/I^n*sinh(n*log(I*(1+sqrt(5))/2)))\/1;</syntaxhighlight>
 
===Chebyshev===
Cookies help us deliver our services. By using our services, you agree to our use of cookies.