We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
WITH RECURSIVE primes as
(
Select 2 as n
union all
select n+1 from primes where n+1<=1000 -- termination statement
)
select group_concat(n SEPARATOR '&') from primes x
where n not in
(
select a
from
(
Select n1.n as a,n2.n as b
from primes n1
inner join primes n2 on n2.n
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Print Prime Numbers
You are viewing a single comment's thread. Return to all comments →
WITH RECURSIVE primes as ( Select 2 as n union all select n+1 from primes where n+1<=1000 -- termination statement )
select group_concat(n SEPARATOR '&') from primes x where n not in ( select a from ( Select n1.n as a,n2.n as b from primes n1 inner join primes n2 on n2.n