xsl-list
[Top] [All Lists]

RE: Fibonacci & XSL

2002-12-17 09:28:01
Jason Macki wrote:
To solve this problem in linear time, do it from the bottom up, not from
the top down.

For example, if you wanted to calculate f(6) dynamically, start with 0
and work up to 6 using the results of the previous two calculations.

F(0) = 1
F(1) = 1
F(2) = f(1) + f(0) = 2
F(3) = f(2) + f(1) = 3
F(4) = f(3) + f(2) = 5
F(5) = f(4) + f(3) = 8
F(6) = f(5) + f(4) = 11


Except, of course, that F(6) = 13

Dan.

-- 
Danny Yates
Technical Architect
Abbey National Treasury Services
E-mail: Danny(_dot_)Yates(_at_)ants(_dot_)co(_dot_)uk
Phone: +44 20 7756 5012
Fax: +44 20 7612 4342


***************************************************************************
This communication (including any attachments) contains confidential 
information.  If you are not the intended recipient and you have received this 
communication in error, you should destroy it without copying, disclosing or 
otherwise using its contents.  Please notify the sender immediately of the 
error.

Internet communications are not necessarily secure and may be intercepted or 
changed after they are sent.  Abbey National Treasury Services plc does not 
accept liability for any loss you may suffer as a result of interception or any 
liability for such changes.  If you wish to confirm the origin or content of 
this communication, please contact the sender by using an alternative means of 
communication.

This communication does not create or modify any contract and, unless otherwise 
stated, is not intended to be contractually binding.

Abbey National Treasury Services plc. Registered Office:  Abbey National House, 
2 Triton Square, Regents Place, London NW1 3AN.  Registered in England under 
Company Registration Number: 2338548.  Regulated by the Financial Services 
Authority (FSA).
***************************************************************************


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>