DEV Community

loading...

Discussion on: What is a SQL query you are proud of?

Collapse
j1cordingley profile image
JCord

I also one day decided to see what would happen if I wrote a query to find all fibonacci prime numbers, it it worked but only if I limited the max number under 2²³ but it gave me a fatal memory error if I try to go bigger higher

I dont have the full code with me but I have the fibonacci query

;with fib as ( select cast(0 as bigint) old_f,cast(1 as bigint) f,1 fno union all select f,f+old_f ,1+fno from fib where f<=( power(cast(2 as bigint),62)) ) select fno , f from fib