This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH RECURSIVE fibs(val, tmp) as ( | |
SELECT 1::NUMERIC, 1::NUMERIC UNION ALL | |
SELECT tmp, val + tmp FROM fibs | |
) | |
SELECT val FROM fibs limit 100 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH ps(v) as ( | |
WITH RECURSIVE t(v) as ( | |
SELECT 3::NUMERIC UNION ALL | |
SELECT v+2 FROM t | |
) | |
SELECT v from t limit 1000 | |
) | |
SELECT 2 UNION ALL | |
SELECT v as prime from ps as candidate | |
WHERE NOT EXISTS ( |