Friday 28 July 2017

To check whether a number is Prime or not.

<?php

   $check=0;
   $num=$_POST['number'];
   for($i=2;$i<=($num/2);$i++)
     { 
       if($num%$i==0)
         {
          $check++;
          if($check==1)
          {
             break;
          }
         }
     }

?>

No comments:

Post a Comment