Prime Numbers:
Prime number is a number that can be divided exactly only by itself and 1, for example 7, 17 and 41 1.
Following code is developed with the help of html, css and php.
Step 1: Go to htdocs folder inside xammp folder.
Step 2: Save file with prime.php
Step 3: Add above code
Step 4: Open xammp server and start apache
Step 5: Type localhost:8080//prime.php on browser
<html>
<head>
<title>Prime Numbers</title>
<link rel="stylesheet" href="char.css">
<style>
*{
margin:0px;
padding:0px;
font-family: cambria;
}
.nav{
background-image: linear-gradient(to bottom right, rgb(178, 115, 207), rgb(59, 185, 108));
padding:10px;
color:white;
text-decoration:bold;
font-size:larger;
}
</style>
</head>
<body>
<div class="nav">
PHP script to display all prime numbers between 1 to 200.
</div>
<br>
<?php
$num=2;
$count=0;
while($count<=200){
$flag=False;
for($i=2;$i<$num/2;$i++){
if(($num%$i)==0){
$flag=True;
}
}
if($flag){
$num=$num+1;
$count=$count+1;
}else{
echo " $num ";
$num=$num+1;
$count=$count+1;
}
}
?>
</body>
</html>
0 Comments