You are on page 1of 4

Practical 12

AIM: write a php program to check the number is prime or not.

input:

expe12.php:

<html>

<head>

<title>Exp12</title>

</head>

<body>

<form method="post">

Enter a Number: <input type="number" name="input"><br><br>

<input type="submit" name="submit" value="CHECK">

</form>

<?php

if($_POST)

$input=$_POST['input'];

for ($i=2;$i<=$input-1;$i++)

if ($input % $i == 0)

$value=true;

if(isset($value) && $value)


200130111058
{

echo 'The Number '.$input. ' is not prime number.';

else

echo 'The Number '. $input . ' is prime number.';

?>

</body>

</html>

Output:

200130111058
Conclusion:

Sign:

200130111058
200130111058

You might also like