write the prime number of program?in php

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


Please Help Members By Posting Answers For Below Questions

What is csrf token and how will you add csrf token in ajax?

523


How cookies are transported from browsers to servers?

494


How we can retrieve the data in the result set of mysql using php?

520


What are the advantages of stored procedures, triggers, indexes in php?

500


What is the difference between $var and $$var?

548






Explain the difference between mysql_connect and mysql_pconnect?

474


What is factory pattern in php?

492


Swap two variables value without using third variable in php ?

589


Is json a string php?

520


Tell me how do you execute a php script from the command line?

511


What is a collection in php?

516


Which function would you use to format date information in php?

546


What is meant by ‘passing the variable by value and reference' in php?

526


Write a php script to get the largest key in an array?

512


What are the characteristics of php?

560