Skip to content

Instantly share code, notes, and snippets.

@c3h3
Forked from hden/fib.sql
Created September 6, 2017 19:11
Show Gist options
  • Select an option

  • Save c3h3/bd165e9ac97f9b1f019bc00e99c8d768 to your computer and use it in GitHub Desktop.

Select an option

Save c3h3/bd165e9ac97f9b1f019bc00e99c8d768 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