Hello folk,
I was browsing through the code and found that fibonacci numbers are
calculated by recursion method. So the time complexity is of O(n) and I
don't expect space complexity be any optimal. It gave me the following
results.
In [1]: %timeit F_n = fibonacci(10)
10 loops, be
Hi,
On 2 August 2011 21:47, Hector wrote:
> Hello folk,
>
> I was browsing through the code and found that fibonacci numbers are
> calculated by recursion method. So the time complexity is of O(n) and I
> don't expect space complexity be any optimal. It gave me the following
> results.
>
> I
On Tue, Aug 2, 2011 at 9:47 PM, Hector wrote:
> Hello folk,
>
> I was browsing through the code and found that fibonacci numbers are
> calculated by recursion method. So the time complexity is of O(n) and I
> don't expect space complexity be any optimal. It gave me the following
> results.
> Ther
On Tue, Aug 2, 2011 at 10:08 PM, Fredrik Johansson
wrote:
> On Tue, Aug 2, 2011 at 9:47 PM, Hector wrote:
>> Hello folk,
>>
>> I was browsing through the code and found that fibonacci numbers are
>> calculated by recursion method. So the time complexity is of O(n) and I
>> don't expect space comp
On Wed, Aug 3, 2011 at 1:42 AM, Vladimir Perić wrote:
> On Tue, Aug 2, 2011 at 10:08 PM, Fredrik Johansson
> wrote:
> > On Tue, Aug 2, 2011 at 9:47 PM, Hector wrote:
> >> Hello folk,
> >>
> >> I was browsing through the code and found that fibonacci numbers are
> >> calculated by recursion metho
What's wrong with the old golden ratio trick to compute the Fibonacci
sequence?.
phi = (1+sqrt(S(5)))/2
def fib(n):
return floor(phi**n / sqrt(5) + S.Half)
map(fib, range(10))
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
On Tue, Aug 2, 2011 at 3:22 PM, Hector wrote:
>
>
> On Wed, Aug 3, 2011 at 1:42
This doesn't work, as you have to take care of precision (try
computing fib(10)). I suspect that it's also slower when you do
that, though Fredrik would have to comment.
Also, note that we already have a GoldenRation object.
Aaron Meurer
On Tue, Aug 2, 2011 at 3:47 PM, Matthew Rocklin wrot
On Wed, Aug 3, 2011 at 12:06 AM, Aaron Meurer wrote:
> This doesn't work, as you have to take care of precision (try
> computing fib(10)). I suspect that it's also slower when you do
> that, though Fredrik would have to comment.
It's a bit slower than than fast integer methods, but only real
On Wed, Aug 3, 2011 at 1:38 AM, Fredrik Johansson <
fredrik.johans...@gmail.com> wrote:
> On Tue, Aug 2, 2011 at 9:47 PM, Hector wrote:
> > Hello folk,
> >
> > I was browsing through the code and found that fibonacci numbers are
> > calculated by recursion method. So the time complexity is of O(n
But be sure to send a python int:
return sympyify(ifib(int(n)))
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To post to this group, send email to sympy@googlegroups.com.
To unsubscribe from this group, send email to
sympy+unsubscr...@googlegro
10 matches
Mail list logo