Skip to content

Instantly share code, notes, and snippets.

@hden
Created May 13, 2015 04:45
Show Gist options
  • Save hden/a7519d5797b5498b52f2 to your computer and use it in GitHub Desktop.
Save hden/a7519d5797b5498b52f2 to your computer and use it in GitHub Desktop.
Fibonacci numbers with SQLite
-- http://www.sqlite.org/lang_with.html --
WITH RECURSIVE
fib(current, next) AS (
SELECT 0 current, 1 next
UNION ALL
SELECT fib.next current, fib.current + fib.next next
FROM fib
LIMIT 20
)
SELECT current FROM fib
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment