This program will print prime numbers in the given range.
the range is given by the user.
DECLARE
i number(3);
j number(3);
num1 number :=&enter_range;
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 = num1;
END LOOP;
END;
the range is given by the user.
DECLARE
i number(3);
j number(3);
num1 number :=&enter_range;
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 = num1;
END LOOP;
END;
No comments:
Post a Comment