Skip to content

Commit

Permalink
Merge pull request hacktoberfest17#268 from UthpalaPitawela/is_prime-php
Browse files Browse the repository at this point in the history
creating a pull request => to check whether a number is prime or not in php
  • Loading branch information
t2013anurag authored Oct 16, 2017
2 parents 33c73aa + d880757 commit 0df7e55
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions is_prime/is_prime.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<html>
<body>
<form action="" method="post">
Enter the numer: <input type="" name="number"><br>
<input type="submit" value="Submit">
</form>
</body>
</html>

<?php
$number = $_POST['number'];

$j=0;
for($i=1;$i<=$number;$i++)
{
if($number % $i == 0)
{
$j++;
}
}

if($j==2)
{
print("prime");
}
else
{
print("not a prime");
}
?>

0 comments on commit 0df7e55

Please sign in to comment.