# Re: [svn:perl6-synopsis] r14586 - doc/trunk/design/syn

```<[EMAIL PROTECTED]> wrote:
> Log:
```
Is there a way for the continuing function to access its index as well
as, or instead of, the values of one or more preceding terms?  And/or
to access elements by counting forward from the start rather than
backward from the end?

There is a mathematical technique whereby any series that takes the
form of "F(n) = A*F(n-1) + B*F(n-2) + C*F(n-3)" can be reformulated as
a function of n, A, B, C, F(0), F(1), and F(2).  (And it is not
limited to three terms; it can be as few as one or as many as n-1 -
although it has to be the same number for every calculated term in the
series.)  For the Fibonacci series, it's something like:

F(n) = (pow((sqrt(5) + 1)/2, n) + pow((sqrt(5) - 1)/2, n))/sqrt(5)

...or something to that effect.  It would be nice if the programmer
were given the tools to do this sort of thing explicitly instead of
having to rely on the optimizer to know how to do this implicitly.

--
Jonathan "Dataweaver" Lang
```