You can enhance the performance of that routine by applying the following mods:

1) When checking for divisors, only check up to the next integer above the square root of the candidiate number.

2) Stop checking for divisors as soon as you find one.

Create or replace procedure prime (p_candidate in integer) as
v_prime boolean := true;
begin
for i in 2..ceil(power(p_candidate,0.5)) loop
if floor(p_candidate/i)*i = p_candidate then
v_prime := false;
exit;
end if;
end loop;
if v_prime then
dbms_output.put_line(p_candidate||' is prime.');
else
dbms_output.put_line(p_candidate||' is not prime.');
end if;
end;

If you fancy wowing the homework instructor with your mathematical skills, you could use an implementation of Wilsons theorem (p is prime IFF (p-1)! +1 is divisible by p)

declare
v_candidate pls_integer := 31;
v_prime boolean := true;
v_fact number := 1;
begin
for i in 2..v_candidate-1 loop
v_fact := v_fact * i;
end loop;
if floor((v_fact+1)/v_candidate)*v_candidate != (v_fact + 1) then
v_prime := false;
end if;
if v_prime then
dbms_output.put_line(v_candidate||' is prime.');
else
dbms_output.put_line(v_candidate||' is not prime.');
end if;
end;