No result found.

Outline

  • Prime no. or not

  • Prime no. or not

Prime No.(PHP)

Varun Chouhan19 Feb, 2020

Prime no. or not

        <!DOCTYPE html>
</head>
<body>
<form action=""method="post">
Enter a no.<input type="text"Name="no">
<input type ="submit "name="ok">

</form>
</body>
</html>
<?PHP
     if(isset <$ post ("ok")>){
        $var=$_post["no"];
        $flag=0;
     for(i=2; $i<$var; $i++){
        if($var%$i==0){
          $flag=1;
      }
}
    if($flag==1){
       echo"$var is not prime";
      }
else
       echo"$var is prime";
      }
}
      

Prime no. or not

        <!DOCTYPE html>
</head>
<body>
<form action=""method="post">
Enter a no.<input type="text"Name="no">
<input type ="submit "name="ok">

</form>
</body>
</html>
<?PHP
     if(isset <$ post ("ok")>){
        $var=$_post["no"];
        $flag=0;
     for(i=2; $i<$var; $i++){
        if($var%$i==0){
          $flag=1;
      }
}
    if($flag==1){
       echo"$var is not prime";
      }
else
       echo"$var is prime";
      }
}