A pl/sql program to display prime numbers in given range
Answers
Answered by
1
DECLARE
fn NUMBER(3);
sn NUMBER(3);
i NUMBER(3);
j NUMBER(3);
BEGIN
fn :=&fn;
sn :=&sn;
dbms_output.Put_line('The prime numbers are:');
dbms_output.new_line;
if fn = 1
then
fn := fn + 1;
end if;
i := fn;
LOOP
j := fn;
LOOP
EXIT WHEN( ( MOD(i, j) = 0 )
OR ( j = i ) );
j := j + 1;
END LOOP;
IF( j = i )THEN
dbms_output.Put(i||' ');
END IF;
i := i + 1;
exit WHEN i = sn;
END LOOP;
dbms_output.new_line;
END;
Similar questions