Here is a simple program that I wrote in PHP as my programming language that will ask the user to give the range from lower bound and upper bound and generate the corresponding prime number from the given range. The code is very easy to undertand and use.
Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
My mobile number here in the Philippines is 09173084360.
My mobile number here in the Philippines is 09173084360.
Sample Program Output
Program Listing
<html>
<head>
<title>
Range of Prime Numbers in PHP
</title>
</head>
<style>
body {
font-family:arial;
font-size :20px;
background-color:lightgreen;
}
input[type=submit]
{
font-size: 20px;
font-weight: bold;
font-family: arial;
background-color: lightblue;
}
</style>
<body>
<?php
error_reporting(0);
$a=$_POST['lower'];
$b=$_POST['upper'];
if(isset($_POST['clear']))
{
$a="";
$b="";
}
?>
<BR>
<h3>Range in Prime Numbers</h3>
<form method="post" action="prime.php" name="prime_me">
Lower Bound <input type="text" name="lower"
size="5" value="<?php echo $a; ?>" autofocus>
Upper Upper Bound <input type="text" name="upper"
size="5" value="<?php echo $b; ?>">
<br><br>
<input type="submit" name="check" value="Ok">
<input type="submit" name="clear" value="Clear">
</form>
<h3> DISPLAY RESULTS </h3>
<?php
if(isset($_POST['check']))
{
$a=$_POST['lower'];
$b=$_POST['upper'];
$flag=0;
for($a;$a<$b;$a++)
{
for($j=2;$j<$a;$j++)
{
if($a%$j==0)
{
$flag=1;
}
}
if($flag==0)
{
echo " ".$a." ";
}
$flag=0;
}
}
?>
</body>
</html>
No comments:
Post a Comment