11 lines
264 B
Text
11 lines
264 B
Text
create or replace function fib(n) as (
|
|
if ( n < 0, error('negative arguments not allowed'),
|
|
(with recursive fib(i,e,f) as (
|
|
select 1, 1, 1
|
|
union all
|
|
select i+1, e+f, e from fib
|
|
where i <= n)
|
|
select last(f order by i)
|
|
from fib)
|
|
)
|
|
);
|