fibonači skaitļu ģenerēšana SQL
Var izmantot arī Pī aprēķināšanai utml.
create type t_array as table of number;
create or replace function fibonaci(p in number)
return t_array
PIPELINED
as
v_n number := 1;
v_n1 number := 1;
v_current number;
begin
for i in 1 .. p loop
if i in (1,2) then
pipe row(1);
else
v_current := v_n + v_n1;
v_n := v_n1;
v_n1 := v_current;
pipe row(v_current);
end loop;
return;
end;
/
select *
from table(fibonaci(10));