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 seq as (select level l1 from dual where level>1 connect by level<=1000)
select listagg(s1.l1,'&')within group(order by s1.l1)
from seq s1
where not exists (select 1 from seq s2
where s2.l1<=sqrt(s1.l1)
and mod(s1.l1,s2.l1)=0);
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 seq as (select level l1 from dual where level>1 connect by level<=1000) select listagg(s1.l1,'&')within group(order by s1.l1) from seq s1 where not exists (select 1 from seq s2 where s2.l1<=sqrt(s1.l1) and mod(s1.l1,s2.l1)=0);