Data update
This commit is contained in:
parent
4d5544505c
commit
4924dd0264
3073 changed files with 55820 additions and 4408 deletions
11
Task/Fibonacci-sequence/DuckDB/fibonacci-sequence-1.duckdb
Normal file
11
Task/Fibonacci-sequence/DuckDB/fibonacci-sequence-1.duckdb
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
create or replace function fib_to(n) as table (
|
||||
with recursive fib(e,f) as (
|
||||
select 1, 1
|
||||
union all
|
||||
select e+f,e from fib
|
||||
where e <= n)
|
||||
select f from fib
|
||||
order by f
|
||||
);
|
||||
|
||||
from fib_to(55);
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
select round ( power( ( 1 + sqrt( 5 ) ) / 2, level ) / sqrt( 5 ) ) fib
|
||||
from range(1,11) t(level);
|
||||
|
|
@ -0,0 +1 @@
|
|||
SELECT 0::UHUGEINT, 1::UHUGEINT
|
||||
16
Task/Fibonacci-sequence/DuckDB/fibonacci-sequence-4.duckdb
Normal file
16
Task/Fibonacci-sequence/DuckDB/fibonacci-sequence-4.duckdb
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
# Warning: the following program has been naively adapted from the PostgresQL but
|
||||
# should be further modified to ensure correctness, e.g. by adding a counter
|
||||
CREATE or replace FUNCTION fib(n) AS (
|
||||
WITH RECURSIVE fibonacci(current, previous) AS (
|
||||
|
||||
SELECT 0::UHUGEINT, 1::UHUGEINT
|
||||
-- another possibility: SELECT 0::FLOAT, 1::FLOAT
|
||||
UNION ALL
|
||||
SELECT previous + current, current FROM fibonacci
|
||||
)
|
||||
SELECT current FROM fibonacci
|
||||
LIMIT 1 OFFSET n
|
||||
);
|
||||
|
||||
# Example
|
||||
select fib(100);
|
||||
Loading…
Add table
Add a link
Reference in a new issue