Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
SQL primes, sqrt sieve
with recursive N as ( select 100000 as N ), lim as ( select (select N from N) as m, sqrt((select N from N))::int as sqrtm ), p(n,step) as ( values(5,2) union all select n + step, step # 6 from p where n + step < (select m + 1 from lim) ), sp(sn,step) as ( values(5,2) union all select sn + step, step # 6 from sp where sn + step < (select sqrtm from lim) ), k as ( select i from generate_series(0,(select m / 5 from lim),2) s(i) ), sieve as ( select sn * sn + i * sn as v from sp inner join k on sn * sn + i * sn < (select m + 1 from lim) ), primes as ( select 2 as n union all select 3 union all select n from p except select * from sieve order by n ) select count(*) from primes;
run
|
edit
|
history
|
help
0
Recursive inefficiency
prec
quiz 1
nested array to table
Assignment 1(SET A)
Join elements by key with json fields
Assignment 1(SET A)
Sush_post1
Codigo_Completo
podd version