Write a program in PL/SQL to check whether a number is prime or not using goto statement with for loop.
Write a program in PL/SQL to check whether a number is prime or not using goto statement with for loop.
Share
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
declare
n number;
i number;
flag number;
begin
i:=2;
flag:=1;
n:=7;
for i in 2..n/2
loop
if mod(n,i)=0
then
flag:=0;
exit;
end if;
end loop;
if flag=1
then
dbms_output.put_line(‘prime’);
else
dbms_output.put_line(‘not prime’);
end if;
end;
/
Output is attached below: