Skip to main content

PL/SQL program for finding a number is Prime or Not


 

-------------Prog 6-------------

declare
  i number(2);
  j number(2);
begin

  i := 2;
  loop
 
    j := 2;
    loop
      exit when((mod(i, j) = 0) or (i = j));
      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;


Comments

Popular posts from this blog

Pl/SQL program to find square of a user input number Using Function

declare   value1 number;   value2 number;   mytotal number;   function myfun(myval1 in number, myval2 in number) return number is     total number;   begin     total := myval1 ** myval2;     dbms_output.put_line(total);     return total;   end; begin   value1 :=&val1;   value2 := &val2;  mytotal:= myfun(value1, value2); end;