Re: calculating fibonacci[was: encryption]

Gerry Quinn <gerryq@xxxxxxxxx> writes:

In article <874p159x2z.fsf@xxxxxxxxx>, ben.usenet@xxxxxxxxx says...
Gerry Quinn <gerryq@xxxxxxxxx> writes:
process Fib ( int n )
small = 1
large = 1
for i = 3 to n
calc = small + large
small = large
large = calc
return large
end process
... I suppose you could do what
my program does and keep the current list pared down to the two most
recent numbers, anyway.

Yes. Richard Harter has posted the functional equivalent of
iterating while holding two previous values.

The Basic function serves equally well as a definition. Knowing how to
calculate the n-th number in a series is a definition of the series.

It serves as a definition, yes, but it may not be as useful for
building the series if that is what you really want. If you call it
repeatedly to make the series you get (roughly) a quadratic
algorithm. If you want a linear function that makes a list (or array
if that is what Basic has) you need to re-write it rather call the


Relevant Pages

  • Re: Mathematics of cornering
    ... I performed a dyslexic percentage calc a few posts ago and escaped without ... I can snip well though :-))) ... mail is beavis dot original at ntlworld dot com ...
  • Re: hpcalc ROM 83 OK
    ... <SNIP> ... My calc goes back to ... > the supplier. ... Ouch! ...
  • Re: Syntax problems to substitute a
    ... <snip, calc produces unwanted Inf's... ... > Have you got any idea to resolve my problem?? ... > (I had thought to put zero when the egN solution is "inf", ... Do your calc and then replace the Inf's with this: ...