In this post I am going to describe the basic PHP Program which tell us about how to find the given number is prime number or not . Prime number are those number which are divisible by 1 and themselves. In this program we are using for loop, if condition and break statement.
<?php
if(isset($_POST['submit'])){
$number= $_POST['number'];
for($i=2;$i<$number;$i++){
if($number/2<$i){
echo "The Given no. is NOT Prime";
break;
}
if($number%$i==0){
echo "The Given no. is Prime";
break;
}
}
}
?>
<html>
<head>
<title>Find Prime</title>
</head>
<body>
<form action="" method='POST'>
<label for="number">Please Enter No</label>
<input type="text" name="number" value="">
<br><br>
<input type="submit" value="Done" name="submit">
</form>
</body>
</html>
Stay tuned for the PHP Magento, WordPress and Magento2 latest tutorial and updates, Hope you enjoyed reading, if you need the professional Magento Development / PHP we can help you, just Click on the Link and send me your requirements.
Please Like the Post on Facebook or Google+.




