Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #87857
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <davea@davea.name> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.010 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'else:': 0.03; 'algorithm': 0.04; 'elif': 0.05; '*not*': 0.07; 'practice,': 0.07; 'subject:missing': 0.07; 'def': 0.12; 'wrote': 0.14; '24,': 0.16; '465': 0.16; 'subject: ?': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'example': 0.22; 'header:User-Agent:1': 0.23; 'question': 0.24; 'possibly': 0.26; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'am,': 0.29; 'is?': 0.30; "d'aprano": 0.31; 'steven': 0.31; 'subject:what': 0.31; 'could': 0.34; 'but': 0.35; 'version': 0.36; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; 'charset:windows-1252': 0.65; 'series': 0.66; 'mar': 0.68; 'received:74.208': 0.68; '2015': 0.84; 'received:74.208.4.194': 0.84; 'toy': 0.84; 'fibonacci': 0.91; 'inefficient': 0.91 |
| Date | Mon, 23 Mar 2015 20:42:07 -0400 |
| From | Dave Angel <davea@davea.name> |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| Subject | Re: fibonacci series what Iam is missing ? |
| References | <CACT3xuVF-MOVQK5wSorRSAfpAQEXvS7QsqarACVZKXsQ0bxzpQ@mail.gmail.com> <mailman.72.1427127417.10327.python-list@python.org> <5510ad7a$0$12979$c3e8da3$5496439d@news.astraweb.com> |
| In-Reply-To | <5510ad7a$0$12979$c3e8da3$5496439d@news.astraweb.com> |
| Content-Type | text/plain; charset=windows-1252; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Provags-ID | V03:K0:1uIqCZcPa0i3TAwKgLFiFnofu262fsjfNGpDu9qhs2T8Ps78CkC I2fIfJHAVBGUaBu9XnyHnfhlnd3zGQG7vtJkjtjYrN2rvID+mFL0+DdJogaTY+7ibiMi17v tuf8YycO9fBVmwFG4/b2PHNnNyc85IxqgbYXSdituArLCrkkJ29IJ6DXVyAIbCVzICG8uAK HIav1cKtbCnHYYO+oUYsw== |
| X-UI-Out-Filterresults | notjunk:1; |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.19 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.89.1427157732.10327.python-list@python.org> (permalink) |
| Lines | 52 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1427157732 news.xs4all.nl 2940 [2001:888:2000:d::a6]:58195 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:87857 |
Show key headers only | View raw
On 03/23/2015 08:19 PM, Steven D'Aprano wrote: > On Tue, 24 Mar 2015 03:16 am, Chris Angelico wrote about the standard > recursive version of the Fibonacci series: > >> On Tue, Mar 24, 2015 at 3:01 AM, Ganesh Pal <ganesh1pal@gmail.com> wrote: > >>> def fib(n): >>> if n == 0: >>> return 0 >>> elif n == 1: >>> return 1 >>> else: >>> return fib(n-1) + fib(n-2) > > >> 2) Your algorithm is about as hopelessly inefficient as it could >> possibly be, barring deliberate intent. > > > It is pretty inefficient, but it is a good toy example of recursion. It's > also a good example of how *not* to write the Fibonacci series in practice, > what is mathematically straightforward is not always computationally > efficient. > > The question is, just how inefficient is is? How many calls to `fib` are > made in calling fib(n)? > > Answer to follow. > > > 0 1 1 1 2 3 3 5 4 9 5 15 6 25 7 41 8 67 9 109 10 177 11 287 12 465 13 753 14 1219 -- DaveA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: fibonacci series what Iam is missing ? Chris Angelico <rosuav@gmail.com> - 2015-03-24 03:16 +1100
Re: fibonacci series what Iam is missing ? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-03-24 11:19 +1100
Re: fibonacci series what Iam is missing ? Dave Angel <davea@davea.name> - 2015-03-23 20:42 -0400
Re: fibonacci series what Iam is missing ? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-03-24 11:56 +1100
Re: fibonacci series what Iam is missing ? Chris Angelico <rosuav@gmail.com> - 2015-03-24 11:59 +1100
Re: fibonacci series what Iam is missing ? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-03-24 12:52 +1100
Re: fibonacci series what Iam is missing ? Rustom Mody <rustompmody@gmail.com> - 2015-03-23 19:23 -0700
Re: fibonacci series what Iam is missing ? Chris Angelico <rosuav@gmail.com> - 2015-03-24 14:03 +1100
Re: fibonacci series what Iam is missing ? Rustom Mody <rustompmody@gmail.com> - 2015-03-23 20:30 -0700
Re: fibonacci series what Iam is missing ? Rustom Mody <rustompmody@gmail.com> - 2015-03-23 21:13 -0700
csiph-web