Language Shootout

Bengt Richter bokr at accessone.com
Tue Jul 10 01:47:19 EDT 2001


On Tue, 10 Jul 2001 03:12:59 GMT, Paul Winkler <slinkp23 at yahoo.com>
wrote:

>OK, I'll bite.
>fibo.py is mine, ffib.py is yours.
>Note that yours computes what is (according to mine and Frederik's scripts)
>fibonacci of N-1 rather than fibonacci of N.
>
I think it's ok for >0, but my fib(0) is plain wrong. A leftover
kludge to make it safe for negative numbers at the same time as
the starting case. Not very pure. I just googled and found 

    http://math.holycross.edu/~davids/fibonacci/fibonacci.html

which seems to agree. Originally I got the sequence definition
from a scheme book with the usual recursive demo examples.
I also just now googled to

    http://www.auto.tuwien.ac.at/~blieb/woop/fibnum.html

where I found not only the definition
   
   F0=0, F1=1, Fn=Fn-1+Fn-2 for n>=2
   This defines the sequence 0, 1, 1, 2, 3, 5, 8, 13, 21 and so on.

but also what appears to be an iterative version or variant of my
recursive algorithm. At least some of the expression terms look
suspiciously similar. But it's written in gnat, and seems to use
lower case L as a variable, which ought to be outlawed, plus
it's got a couple Ada tricks I don't recognize. But at some point
I'd like to translate it to Python for comparison. It should be
the fastest. Of course it won't be recursive.

>Other than that, you've kicked my butt!
>
>Now is the time for me to strategically retreat and declare that what really
>matters is readability. Who cares about speed? Not me! Never did, no sir. 
>
LOL, thanks for the chuckle ;-)




More information about the Python-list mailing list