Code:
<!DOCTYPE html><html>
<body>
<center><h1>PRIME NUMBERS IN RANGE</h1>
<?php
if (isset($_POST['find']))
{
$i=$_POST['lower'];
$k=$_POST['upper'];
$flag=0;
for($i;$i<$k;$i++)
{
for($j=2;$j<$i;$j++)
{
if($i%$j==0)
{
$flag=1;
}
}
if($flag==0)
{
echo "$i <br>";
}
$flag=0;
}
}
?>
<form method="post" action="index.php">
Lower limit: <input type="text" name="lower">
Upper limit: <input type="text" name="upper">
<input type="submit" name="find" value="Find">
</form>
</center>
</body>
</html>
No comments:
Post a Comment