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.
create procedure prime ()
begin
declare i, d, c int;
declare result varchar (1000);
set i = 2;
set result = ' ';
while i < 1000 do
set d = 1;
set c = 0;
while d <= i do
if i % d = 0 then
set c = c+1;
end if;
set d=d+1;
end while;
if c=2 then
set result = concat (result, i, '&');
end if;
set i = i+1;
end while;
select left (result, char_length(result)-1) as primes;
end
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 →
delimiter $$
create procedure prime () begin declare i, d, c int; declare result varchar (1000); set i = 2; set result = ' ';
end