Tag: fibonacci

Fibonacci Rides Again

Not so long ago I wrote about implementing GCD function in PostgreSQL using CTE.

Here I will show how Fibonacci Numbers may be obtained using the same technique.

So to have first 16 members of this sequence we should execute something like this:

    VALUES (11)
    SELECT b, a + b FROM t

Suppose we should add this code to Wiki Library Snippets. Any objections? ;)

UPD. Some others unnatural ways to calculate Fibonacci numbers may be found in Russian.