Data update
This commit is contained in:
parent
81fd053722
commit
52a6ef48dd
10248 changed files with 63654 additions and 6775 deletions
20
Task/Fibonacci-sequence/SQL/fibonacci-sequence-5.sql
Normal file
20
Task/Fibonacci-sequence/SQL/fibonacci-sequence-5.sql
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
SET @row_count := 10;
|
||||
WITH RECURSIVE fibonacci_row (seq, current_value, next_value) AS
|
||||
(
|
||||
(
|
||||
SELECT
|
||||
CAST(1 AS UNSIGNED INTEGER) AS seq,
|
||||
CAST(0 AS UNSIGNED INTEGER) AS current_value,
|
||||
CAST(1 AS UNSIGNED INTEGER) AS next_value
|
||||
) UNION ALL (
|
||||
SELECT
|
||||
seq + 1 AS seq,
|
||||
next_value AS current_value,
|
||||
current_value + next_value AS next_value
|
||||
FROM fibonacci_row
|
||||
WHERE seq + 1 <= @row_count
|
||||
)
|
||||
)
|
||||
SELECT seq, current_value
|
||||
FROM fibonacci_row
|
||||
;
|
||||
Loading…
Add table
Add a link
Reference in a new issue