It worked for me.

SQL> set serveroutput on
SQL> DECLARE
i NUMBER(3);
j NUMBER(3);
BEGIN
i := 2;
LOOP
j := 2;
LOOP
EXIT WHEN ( ( MOD(i, j) = 0 )
OR ( j = i ) );
j := j + 1;
END LOOP;
IF ( j = i ) THEN
dbms_output.Put_line(i
|| ' is prime');
END IF;
i := i + 1;
exit WHEN i = 50;
END LOOP;
END;
/ 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
2 is prime
3 is prime
5 is prime
7 is prime
11 is prime
13 is prime
17 is prime
19 is prime
23 is prime
29 is prime
31 is prime
37 is prime
41 is prime
43 is prime
47 is prime
PL/SQL procedure successfully completed.
SQL>