Friday, January 1, 2016

Check Prime Number by using PHP

<?php
if(isset($_POST['Check'])) {
$checkNumber = $_POST['number'];

if($checkNumber %2 !== 0 && $checkNumber / $checkNumber == 1 )
{
echo "<h1>" . $checkNumber . "   " . "Prime Number" . "</h1>";
}
elseif($checkNumber % 2 ==0)
{
echo "<h1>" . $checkNumber . "   " . "Not Prime Number" . "</h1>";
}
else{
echo "<h3>" . "Nothing Found ! Please Input Number To Ckeck Prime ?" . "</h3>";
}
}
?>

<form name="myForm" method="post" action="">
Input Number:
<input type="text" name="number" placeholder="Input Number">
<input type="submit" name="Check" value="Check">
</form>

No comments:

Post a Comment