Created
July 4, 2015 13:22
-
-
Save developer-anuragsingh/a4cbb26b40731470cd5e to your computer and use it in GitHub Desktop.
Find all the Prime numbers with the PHP function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function find_prime_nums($start, $end){ | |
for($i=$start; $i<=$end; $i++){ | |
$counter = 0; | |
for($j=1; $j<=$i; $j++){ | |
if($i%$j == 0){ | |
$counter++; | |
} | |
} | |
if($counter == 2) { | |
echo "$i - is a prime number. <br/>"; | |
} | |
} | |
} | |
find_prime_nums(2,10); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment