PHP Code:
<!DOCTYPE html>
<html>
<head>
<style>
input{
width: 200px;
font-size: 20px;
padding: 10px;
margin: 10px;
}
</style>
</head>
<body>
<h3>Php Code to check if number is prime or not</h2>
<form method="$_GET">
<input type="number" placeholder="Enter a Number.." name="number" />
<input type="submit" name="send" />
</form>
<?php
if (isset($_GET['send'])){
$number = $_GET['number'];
$count = 0;
for ($i = 1; $i <= $number; $i++){
$res = $number % $i;
if ($res == 0){
$count++;
}
}
if ($count < 3){
echo "<h3>",$number, " Number is Prime</h3>";
}
else{
echo "<h3>",$number, " Number is Not Prime</h3>";
}
$count = 0;
$number = 0;
$res = 0;
}
?>
</body>
</html>
Output:
Comments
Post a Comment