PL/SQL block to check if a number is Prime

Q. Write a PL/SQL block to check weather a given number is Prime or not.

Answer:

Prime number: It is a natural number greater than 1 and has no positive divisor other than 1 and itself.

For Example:
5 is prime number because, number 5 has  1 and 5 are only positive integer factors.

The following program will check weather a given number is prime or not.

  declare
       num number;
       i number:=1;
       c number:=0;
  begin
        num:=#
       for i in 1..num
       loop
          if((mod(num,i))=0)
           then
              c:=c+1;
         end if;
      end loop;
     if(c>2)
     then
         dbms_output.put_line(num||' not a prime');
     else
        dbms_output.put_line(num||' is prime');
     end if;
  end;
   /


Output:

prime number