Answer Posted / akvh
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form action="" method="post">
Enter the number: <input type="text" name="num" />
<input type="submit" name="sub" />
</form>
<?php
if(isset ($_POST['sub']))
{
$a=$_POST['num'];
$i=2;
$f=0;
while($i<=($a/2))
{
if($a%$i==0)
{
$f=1;
break;
}
$i++;
}
if($f==1)
{
echo "NOT PRIME";
}
else
{
echo "PRIME";
}
}
?>
</body>
</html>
| Is This Answer Correct ? | 13 Yes | 1 No |
Post New Answer View All Answers
When are you supposed to use endif to end the conditional statement?
How can you declare the array in php?
What is php and its advantages?
What is meant by variable variables in php?
Differences between get, post and request methods ?
How can we display information of a variable and readable by human with php?
Tell me what is the main difference between php 4 and php 5?
How to take a substring from a given string?
How do we get the current session id?
Do you know how can we check the value of a given variable is a number?
How to split a string into array using php?
What is difference between Method overriding and overloading in PHP?
Explain array_uintersect()?
Does browser understand php?
How to write php function in html onclick?