Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Gregory Ewing Newsgroups: comp.lang.python Subject: Re: fibonacci series what Iam is missing ? Date: Tue, 24 Mar 2015 20:54:42 +1300 Lines: 23 Message-ID: References: <55105EF4.2070805@davea.name> <55109DEF.9070001@davea.name> <5510AB29.8060105@davea.name> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net f1zlbIjRyvfQhJF9/ulBvA28LN8A/0z6FXR9VZyAG+OIUBq01w Cancel-Lock: sha1:x3chycE+f6GKibCW2NddTRDPy3M= User-Agent: Mozilla Thunderbird 1.0.5 (Macintosh/20050711) X-Accept-Language: en-us, en In-Reply-To: Xref: csiph.com comp.lang.python:87874 Chris Angelico wrote: > Commenting is like dieting. You can always start tomorrow. I've been meaning to become a procrastinator, but I think I'll start tomorrow. In the meantime, since we seem to be having a fibbing competition, here's my contribution, that uses neither recursion nor (explicit) iteration: from numpy import array, dot a = array([[0,1],[1,1]]) b = array([0,1]) def fib(n): return reduce(dot,[a]*n+[b])[1] for i in range(10): print(fib(i)) -- Greg