PL/SQL Program for Prime Number
Prime Number:-Prime number is a number if it is divisible by 1 or itself. For example 2, 3, 5, 7, etc are prime numbers
declare
num number;
k number;
flag number;
begin
k:=2;
flag:=1;
num:=7;
for k in 2..num/2
loop
if mod(num,k)=0
then
flag:=0;
exit;
end if;
end loop;
if flag=1
then
dbms_output.put_line('Input number is a prime number');
else
dbms_output.put_line('Input number is not a prime number');
end if;
end;
/
Output:-
Input number is a prime number