[Tutor] fibonacci

Ike Hall Ike Hall <hall@nhn.ou.edu>
Wed Feb 12 01:30:03 2003


Actually, the Fibonacci Sequence is quite simple,

its 1,1,2,3,5,8,13,....

each number is the sum of the previous 2....


writing a program to do this would be simple as well...

def fib(index):
    first=1
    second=1
    for i in range(index):
        new=first+second
        first=second
        second=new
    return new

then this function would give the nth number in a fibonacci sequence

----- Original Message ----- 
From: "Mic Forster" <micforster@yahoo.com>
To: <tutor@python.org>
Sent: Tuesday, February 11, 2003 8:01 PM
Subject: Re: [Tutor] fibonacci


> 
> --- Danny Yoo <dyoo@hkn.eecs.berkeley.edu> wrote:
> > Counterquestion: what is the fibonacci sequence? 
> > *grin*
> > 
> > 
> > But seriously speaking: pretend that none of us on
> > the list know what the
> > "fibonacci sequence" is, and try explaining it to
> > us.  Since concrete
> > examples help clear our head, it might also be
> > helpful to show us what the
> > first few terms of these sequence are.
> > 
> > You may find that explaining it to a human can help
> > you figure out how to
> > program a computer how to do it!
> > 
> 
> 
> Danny,
> 
> That's not bad advice. I have been told before that if
> you cannot explain a scientific theory to a 6 year
> old, and make them understand, then it is not much of
> a theory. The same could be said of computer programming.
> 
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Shopping - Send Flowers for Valentine's Day
> http://shopping.yahoo.com
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>