3 comments:

  1. $num1=$_POST["num"];
    $flag=0;
    for($i=2;$i<=$num1/2;$i++)
    {
    if($num1%$i==0)
    {
    $flag=1;
    break;
    }
    }
    if($flag==1)
    {
    echo "Number is not prime";
    }
    else
    echo "Prime";

    ReplyDelete
  2. php
    $low=$_POST['num']; // low variable for starting range
    $high=$_POST['num1']; // high variable for ending range
    while($low<$high)
    { $flag=0;
    for($i=2;$i<$low;$i++)
    { if($low%$i==0)
    {$flag=1;
    break;
    }
    }
    if($flag==0)
    echo"
    $low is an prime number";
    else
    echo"
    $low is not a prime number";
    ++$low;
    }

    ReplyDelete
  3. $num=$_POST["n"];
    $flag=0;
    for($i=2;$i<=$num/2;$i++)
    {
    if($num%$i==0)
    {
    $flag=1;
    break;
    }
    }
    if($flag==1)
    {
    echo "Number is not prime";
    }
    else
    echo "Prime";

    ReplyDelete