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.
Select LISTAGG(lvl1, '&') WITHIN GROUP (ORDER BY lvl1) from (
Select lvl1,count(Case when Mod(lvl1,lvl2)=0 THEN 1 END) as divisor from
(Select level lvl1 from dual connect by level <=1000) A,
(Select level lvl2 from dual connect by level <=1000) B
group by lvl1)
where divisor in (1,2) order by lvl1 asc;
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 →
Select LISTAGG(lvl1, '&') WITHIN GROUP (ORDER BY lvl1) from ( Select lvl1,count(Case when Mod(lvl1,lvl2)=0 THEN 1 END) as divisor from (Select level lvl1 from dual connect by level <=1000) A, (Select level lvl2 from dual connect by level <=1000) B group by lvl1) where divisor in (1,2) order by lvl1 asc;